Menu

#130 special cases for comparison: URI userinfo is case sensitive

ver devel
closed-fixed
core (32)
5
2009-01-19
2008-08-11
No

Hi, Kamailio matches the following when RURI="sip:aa@domain.com":

if ($rU == "Aa") => returns true

But this is not valid since userinfo part of an URI is case *sensitive* (but not the protocol, domain, uri parameters and header parameters):

--------------
19.1.4 URI Comparison

o Comparison of the userinfo of SIP and SIPS URIs is case-
sensitive. This includes userinfo containing passwords or
formatted as telephone-subscribers. Comparison of all other
components of the URI is case-insensitive unless explicitly
defined otherwise.
--------------

Also, URI parameters matching in Kamailio is wrong since it compares all the parameters in URI A with all parameters in URI B. For example, Kamamilio says those two URI's are not equal when in fact they are:

URI A = sip:aa@domain;kk
URI A = sip:aa@domain;qq

--------------
o URI uri-parameter components are compared as follows:

- Any uri-parameter appearing in both URIs must match.

- A user, ttl, or method uri-parameter appearing in only one
URI never matches, even if it contains the default value.

- A URI that includes an maddr parameter will not match a URI
that contains no maddr parameter.

- All other uri-parameters appearing in only one URI are
ignored when comparing the URIs.
--------------

Well, I think this is a pain, but near 60% in SIP is a pain XD

Discussion

  • Daniel-Constantin Mierla

    Logged In: YES
    user_id=1246013
    Originator: NO

    The string operations in script are case insensitive. avp_check() can do case sensitive comparisons.

    As operations flexibility give configuration file power, we would need a new set of operators to differentiate between case sensitive and insensitive. Alternative is to introduce function in core like strcmp/strcasecmp.

     
  • Olle E. Johansson

    Logged In: YES
    user_id=7341
    Originator: NO

    URI comparision is a bit more complicated than strcmp, so in that case we need a uricmp() function. However, the username part only is a bit more easy.

     
  • Iñaki Baz Castillo

    Logged In: YES
    user_id=1844020
    Originator: YES

    @miconda:
    > The string operations in script are case insensitive. avp_check() can do
    > case sensitive comparisons.

    I can sure that the following comparisions are case insensitive in Kamailio so I assume they are not "normal" string operations:

    1) $rU == "Aa"
    2) $rd == "doMAin.cOM"
    3) uri == "SIp:AA@DOMAin.com"

    Al of those comparisions return true if the RURI = "sip:aa@domain.com", but 1) is wrong since userinfo MUST be case sensitive as per RFC 3261.

    @oej:
    > URI comparision is a bit more complicated than strcmp, so in that case
    > we need a uricmp() function. However, the username part only is a bit more
    > easy.

    Also take in count that:

    - URI protocol: case insensitive ("sip" == "SIp")

    - URI userinfo: case sensitive, allows hexadecimal escaping ("alice" == "%61alice != "Alice")

    - URI host: case insensitive ("kamailio.org" == "KAMAIlio.org")

    - URI parameters (key and value): case insensitive, allows hexadecimal escaping ("tag=alice" == "T%61G=%61aliCE")
    Also note that if the host is a IPv4 or IPv6 then binary matching must be permormed ("1.2.3.4 == 1.002.03.4").

    - URI headers: (I prefer to forget those useles URI components...).

     
  • Daniel-Constantin Mierla

    Logged In: YES
    user_id=1246013
    Originator: NO

    The comparisons make no difference of what pseudo-variable is compared. The evaluation of the expressions is getting the values for left and right side operands and then compare as string. That maybe dedicated functions will bring something much more clear.

     
  • Daniel-Constantin Mierla

    Logged In: YES
    user_id=1246013
    Originator: NO

    Moved this discussion to feature requests, as seems that special functions are required for dedicated cases

     
  • Daniel-Constantin Mierla

    • labels: 780601 --> core
    • milestone: 537593 --> ver devel
    • summary: URI userinfo is case sensitive --> special cases for comparison: URI userinfo is case sensitive
     
  • Daniel-Constantin Mierla

    • assigned_to: nobody --> miconda
    • status: open --> closed-fixed
     
  • Daniel-Constantin Mierla

    siputils module includes now functions to compare uri and aor.

     

Log in to post a comment.