Looks like there is bug in {param.count,delimiter} transformation:
$var(test) = "a=1;b=2"; xinfo("param count = $(var(test){param.count,;})\n"); $var(test) = "a=1,b=2"; xinfo("param count = $(var(test){param.count,,})\n");
syslog:
Aug 19 11:27:27 salmon /usr/bin/sip-proxy[26513]: INFO: param count = 2 Aug 19 11:27:27 salmon /usr/bin/sip-proxy[26513]: INFO: param count = 1
-- Juha
Hello,
iirc, the comma does not work as delimiter between parameters, because it is the delimiter between the header bodies (when many bodies are serialized within same header name).
If someone wants that, then should be extended, but careful not to break SIP header parsing.
An alternative is to replace comma with another char (use subst transformation) and then use the param transformation.
Cheers, Daniel
On 19.08.19 10:31, Juha Heinanen wrote:
Looks like there is bug in {param.count,delimiter} transformation:
$var(test) = "a=1;b=2"; xinfo("param count = $(var(test){param.count,;})\n"); $var(test) = "a=1,b=2"; xinfo("param count = $(var(test){param.count,,})\n");
syslog:
Aug 19 11:27:27 salmon /usr/bin/sip-proxy[26513]: INFO: param count = 2 Aug 19 11:27:27 salmon /usr/bin/sip-proxy[26513]: INFO: param count = 1
-- Juha
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Daniel-Constantin Mierla writes:
iirc, the comma does not work as delimiter between parameters, because it is the delimiter between the header bodies (when many bodies are serialized within same header name).
I thought that comma can be used as param.count delimiter, because it works as select delimiter:
https://www.kamailio.org/wiki/cookbooks/devel/transformations#sselect_index_...
-- Juha
On 19.08.19 12:21, Juha Heinanen wrote:
Daniel-Constantin Mierla writes:
iirc, the comma does not work as delimiter between parameters, because it is the delimiter between the header bodies (when many bodies are serialized within same header name).
I thought that comma can be used as param.count delimiter, because it works as select delimiter:
https://www.kamailio.org/wiki/cookbooks/devel/transformations#sselect_index_...
That's pure string tokenizer -- find the separator in the buffer and advance to next token.
The param transformation is using the parser for SIP header/URI parameters, where comma is not a separator for parameters, but for header/uri bodies.
I think it may work with some workaround done in pv module -- iirc, the pv module is cloning the value in a local buffer, so then it can replace the comma separator with another one (set by modparam or so) in the local buffer, so it doesn't impact the original value and it doesn't require to change the sip param parser.
Cheers, Daniel
One alternative could be to implement
{s.count, delimiter}
which would tell how many items a list separated by delimiter has.
-- Juha
On 19.08.19 14:30, Juha Heinanen wrote:
One alternative could be to implement
{s.count, delimiter}
which would tell how many items a list separated by delimiter has.
That can be added, probably it would be just a generic {s.count,char} => return the number of appearances of char in the value.
Then for a param-like list with such delimiter it has to add 1. However, for this specific case, to have a proper context parsing, in order to be sure the params are well formatted, it should not be just a bare string walk through.
Cheers, Daniel
Daniel-Constantin Mierla writes:
One alternative could be to implement
{s.count, delimiter}
which would tell how many items a list separated by delimiter has.
That can be added, probably it would be just a generic {s.count,char} => return the number of appearances of char in the value.
Then for a param-like list with such delimiter it has to add 1. However, for this specific case, to have a proper context parsing, in order to be sure the params are well formatted, it should not be just a bare string walk through.
In my current use case, the list is not a parameter list, but any list. So s.count would suffice.
-- Juha
On 19.08.19 14:41, Juha Heinanen wrote:
Daniel-Constantin Mierla writes:
One alternative could be to implement
{s.count, delimiter}
which would tell how many items a list separated by delimiter has.
That can be added, probably it would be just a generic {s.count,char} => return the number of appearances of char in the value.
Then for a param-like list with such delimiter it has to add 1. However, for this specific case, to have a proper context parsing, in order to be sure the params are well formatted, it should not be just a bare string walk through.
In my current use case, the list is not a parameter list, but any list. So s.count would suffice.
OK. That should be easy, I can add it later today or latest tomorrow, if nobody else does it meanwhile.
Cheers, Daniel
I just pushed the commit adding the {s.count,c} parameter:
* https://github.com/kamailio/kamailio/commit/18eb1c973c5d863a562864c2b77b4e1d...
Can you try it and see if works fine? I didn't have any time for testing yet ...
Cheers, Daniel
On 19.08.19 14:44, Daniel-Constantin Mierla wrote:
On 19.08.19 14:41, Juha Heinanen wrote:
Daniel-Constantin Mierla writes:
One alternative could be to implement
{s.count, delimiter}
which would tell how many items a list separated by delimiter has.
That can be added, probably it would be just a generic {s.count,char} => return the number of appearances of char in the value.
Then for a param-like list with such delimiter it has to add 1. However, for this specific case, to have a proper context parsing, in order to be sure the params are well formatted, it should not be just a bare string walk through.
In my current use case, the list is not a parameter list, but any list. So s.count would suffice.
OK. That should be easy, I can add it later today or latest tomorrow, if nobody else does it meanwhile.
Cheers, Daniel
Documentation seems also missing at https://www.kamailio.org/wiki/cookbooks/devel/transformations
Cheers,
Henning
Am 20.08.19 um 11:22 schrieb Daniel-Constantin Mierla:
I just pushed the commit adding the {s.count,c} parameter:
* https://github.com/kamailio/kamailio/commit/18eb1c973c5d863a562864c2b77b4e1d...
Can you try it and see if works fine? I didn't have any time for testing yet ...
Cheers, Daniel
On 19.08.19 14:44, Daniel-Constantin Mierla wrote:
On 19.08.19 14:41, Juha Heinanen wrote:
Daniel-Constantin Mierla writes:
One alternative could be to implement
{s.count, delimiter}
which would tell how many items a list separated by delimiter has.
That can be added, probably it would be just a generic {s.count,char} => return the number of appearances of char in the value.
Then for a param-like list with such delimiter it has to add 1. However, for this specific case, to have a proper context parsing, in order to be sure the params are well formatted, it should not be just a bare string walk through.
In my current use case, the list is not a parameter list, but any list. So s.count would suffice.
OK. That should be easy, I can add it later today or latest tomorrow, if nobody else does it meanwhile.
Cheers, Daniel