[SR-Users] Missing line in line.count transformation
miconda at gmail.com
Thu Oct 7 09:28:20 CEST 2021
can you try with the patch from commit:
If works, then I will backport.
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.
On 06.10.21 16:45, Daniel Donoghue wrote:
> I think I’ve found an edge case with the string transformations for
> In pv_trans.c, the following code does not appear to consider the last
> line if there are multiple lines and the last one is not terminated
> with \n.
> case TR_LINE_COUNT:
> for(i=0; i<val->rs.len; i++)
> 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);
> This means that my count is always one off unless I force a blank line
> at the end of my string.
> 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
> s.replace with hexadecimal escape codes (\r and \n do not work) in a
> With every blessing,
> Daniel Donoghue
> Kamailio - Users Mailing List - Non Commercial Discussions
> * sr-users at lists.kamailio.org
> Important: keep the mailing list in the recipients, do not reply only to the sender!
> Edit mailing list options or unsubscribe:
> * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio Advanced Training - Online
Nov 08-11, 2021 (Europe Timezone) - Nov 22-25, 2021 (America Timezone)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the sr-users