Hello,<div><br></div><div>you can also convert the header value to integer using the transformation {<a href="http://s.int">s.int</a>}, that's safer if you need to do other types of comparison such as > or <, because comparing string values might give the result you don't expect,</div><div><br></div><div>Cheers,</div><div>Daniel<br><br>On Friday, September 13, 2019, Joel Serrano <<a href="mailto:joel@textplus.com">joel@textplus.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I think I found the solution to my problem: I'm comparing to 0 (number) when I should be comparing to "0" (string)?<div><br></div><div>Using:</div><div><br></div><div>...</div><div>        if ($hdr(Expires)=="0" || $sel(contact.expires)=="0") {<br></div><div>...</div><div><br></div><div>Is working as expected.</div><div><br></div><div>Sorry for the noise!</div><div>Joel.</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Sep 12, 2019 at 5:50 PM Joel Serrano <<a href="mailto:joel@textplus.com" target="_blank">joel@textplus.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello, <br><div><br></div><div>I'm running into what I believe a weird situation when comparing <null> to 0.</div><div><br></div><div>I have the following lines:</div><div><font face="monospace"><br></font></div><div><font face="monospace">        xlog("L_NOTICE", "DEBUG: sel(contact.expires)=$sel(<wbr>contact.expires) - hdr(Expires)=$hdr(Expires)\n")<wbr>;<br></font></div><div><font face="monospace">        if ($hdr(Expires)==0 || $sel(contact.expires)==0) {<br>            xlog("L_NOTICE", "[end] removed user location\n");<br>        } else {<br>            xlog("L_NOTICE", "[end] saved user location\n");<br>        }</font><br></div><div><br></div><div>I registered with 3 devices, one sends expires as header, another as contact param, and the last uses both header AND contact param.</div><div><br></div><div>My surprise was this:</div><div><br></div><div><br></div><div>1- Both header and contact param:</div><div><pre style="margin-top:4px;margin-bottom:4px;padding:8px;font-size:12px;line-height:1.50001;white-space:pre-wrap;word-break:normal;border-radius:4px;color:rgb(29,28,29);font-family:Monaco,Menlo,Consolas,"Courier New",monospace">Sep 12 19:37:48 csbc01 csbc[8036]: NOTICE: {1 4 REGISTER 02c3ea6ee623916d37532188031017<wbr>c9@0:0:0:0:0:0:0:0} <script>: DEBUG: sel(contact.expires)=600 - hdr(Expires)=600<br>Sep 12 19:37:48 csbc01 csbc[8036]: NOTICE: {1 4 REGISTER 02c3ea6ee623916d37532188031017<wbr>c9@0:0:0:0:0:0:0:0} <script>: [end] saved user location</pre></div><div>2- Only contact param:</div><div><pre style="margin-top:4px;margin-bottom:4px;padding:8px;font-size:12px;line-height:1.50001;white-space:pre-wrap;word-break:normal;border-radius:4px;color:rgb(29,28,29);font-family:Monaco,Menlo,Consolas,"Courier New",monospace">Sep 12 19:36:15 csbc01 csbc[8035]: NOTICE: {1 40629 REGISTER <a href="mailto:f2cbaa53-eabfd633@84.121.150.224" target="_blank">f2cbaa53-eabfd633@84.121.150.<wbr>224</a>} <script>: DEBUG: sel(contact.expires)=600 - hdr(Expires)=<null><br>Sep 12 19:36:15 csbc01 csbc[8035]: NOTICE: {1 40629 REGISTER <a href="mailto:f2cbaa53-eabfd633@84.121.150.224" target="_blank">f2cbaa53-eabfd633@84.121.150.<wbr>224</a>} <script>: [end] removed user location</pre></div><div><div>2- Only header:</div><div><pre style="margin-top:4px;margin-bottom:4px;padding:8px;font-size:12px;line-height:1.50001;white-space:pre-wrap;word-break:normal;border-radius:4px;color:rgb(29,28,29);font-family:Monaco,Menlo,Consolas,"Courier New",monospace">Sep 12 19:29:33 csbc01 csbc[8033]: NOTICE: {1 402 REGISTER <a href="mailto:2_1804628355@192.168.30.31" target="_blank">2_1804628355@192.168.30.31</a>} <script>: DEBUG: sel(contact.expires)=<null> - hdr(Expires)=3600<br>Sep 12 19:29:33 csbc01 csbc[8033]: NOTICE: {1 402 REGISTER <a href="mailto:2_1804628355@192.168.30.31" target="_blank">2_1804628355@192.168.30.31</a>} <script>: [end] removed user location</pre></div></div><div><br></div><div><br></div><div>I can workaround the header by using is_present_hf() before comparing, I can also probably parse the $ct to see if it has some Expires in it, but I really want to know if my understanding is incorrect and I'm doing something wrong or if this is a bug?</div><div><br></div><div>Thanks!<br></div><div>Joel.</div><div><br></div></div>
</blockquote></div>
</blockquote></div><br><br>-- <br><div dir="ltr"><div><div dir="ltr"><div>Daniel-Constantin Mierla - <a href="http://www.asipto.com" target="_blank">http://www.asipto.com</a></div><div><a href="http://twitter.com/#!/miconda" target="_blank">http://twitter.com/#!/miconda</a> - <a href="http://www.linkedin.com/in/miconda" target="_blank">http://www.linkedin.com/in/miconda</a></div></div></div></div><br>