<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Daniel,<div class=""><br class=""></div><div class="">Thanks for the prompt response. </div><div class=""><br class=""></div><div class="">Unfortunately, I am not in a position to be able to build kamailio from source at the moment, I noticed this issue on our production servers, using prebuilt binaries from apt repos but the code, at first glance, looks like it should work.</div><div class=""><br class=""></div><div class="">We are using a db to inject headers into outbound INVITEs and the db is filled using db tools running on Mac laptops; this means that I have been able to instruct our staff to ensure they press enter at the end of each line. It also means I had to do a fix in kamailio to convert mac’s line terminator, 0x0a, to a linux terminator, 0x0d, in order for the line counting and separation to work at all, which is why I made a suggestion for a new transformation that could do that for us… trim won’t work as the field is multi-line.</div><div class=""><br class=""></div><div class="">Blessings,</div><div class="">—</div><div class="">Daniel</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 7 Oct 2021, at 09:28, Daniel-Constantin Mierla <<a href="mailto:miconda@gmail.com" class="">miconda@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
  
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" class="">
  
  <div class=""><p class="">Hello,</p><p class="">can you try with the patch from commit:</p><p class="">  *
<a class="moz-txt-link-freetext" href="https://github.com/kamailio/kamailio/commit/eaec3aaac227eb4a8c48f93b45565d15d4a0a991">https://github.com/kamailio/kamailio/commit/eaec3aaac227eb4a8c48f93b45565d15d4a0a991</a></p><p class="">If works, then I will backport.</p><p class="">The transformation is designed for working with lines in sip
      message that are terminated with CRLF, by searching for LF (\n) to
      cover the unix/dos. If you want to remove \r, there is a string
      trim transformation. I haven't seen lines finished only with \r
      flowing in the SIP world, but feel free to add new features in the
      code and propose pull requests via github project portal.</p><p class="">Cheers,<br class="">
      Daniel<br class="">
    </p>
    <div class="moz-cite-prefix">On 06.10.21 16:45, Daniel Donoghue
      wrote:<br class="">
    </div>
    <blockquote type="cite" cite="mid:BA5F20C6-0B7C-457E-858C-D0F5946CE576@freespee.com" class="">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" class="">
      I think I’ve found an edge case with the string transformations
      for line.count:
      <div class=""><br class="">
      </div>
      <div class="">In <font class="" face="Menlo">pv_trans.c</font>,
        the following code does not appear to consider the last line if
        there are multiple lines and the last one is not terminated with
        <font class="" face="Menlo">\n</font>.</div>
      <div class=""><br class="">
      </div>
      <div class="">
        <pre style="background-color: rgb(255, 255, 255); font-family: Menlo; font-size: 9pt;" class="">case TR_LINE_COUNT:
    n=0;
    for(i=0; i<val->rs.len; i++)
        if(val->rs.s[i]=='\n')
            n++;
    if(n==0 && val->rs.len>0)
        n = 1;
    val->flags = PV_TYPE_INT|PV_VAL_INT|PV_VAL_STR;
    val->ri = n;
    val->rs.s = int2str(val->ri, &val->rs.len);
    break;

</pre>
        <div class="">This means that my count is always one off unless
          I force a blank line at the end of my string.</div>
      </div>
      <div class=""><br class="">
      </div>
      <div class=""><br class="">
      </div>
      <div class="">Also, this code does not cater for cases where there
        is a different line terminator, such as CR or CRLF as is the
        case when the string comes from a Mac or windows system,
        respectively; it might be useful to have a transformation for
        doing that as I’ve had to hack it using <font class="" face="Menlo">s.replace</font> with hexadecimal escape codes (<font class="" face="Menlo">\r</font> and <font class="" face="Menlo">\n</font> do not work) in a variable.</div>
      <div class=""><br class="">
      </div>
      <div class=""><br class="">
      </div>
      <div class="">With every blessing,</div>
      <div class="">—</div>
      <div class="">Daniel Donoghue</div>
      <div class=""><br class="">
      </div>
      <br class="">
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
  * <a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a>
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe:
  * <a class="moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla -- <a class="moz-txt-link-abbreviated" href="http://www.asipto.com/">www.asipto.com</a>
<a class="moz-txt-link-abbreviated" href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a class="moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a>
Kamailio Advanced Training - Online
Nov 08-11, 2021 (Europe Timezone) - Nov 22-25, 2021 (America Timezone)
  * <a class="moz-txt-link-freetext" href="https://www.asipto.com/sw/kamailio-advanced-training-online/">https://www.asipto.com/sw/kamailio-advanced-training-online/</a></pre>
  </div>

</div></blockquote></div><br class=""></div></body></html>