[Home]

Summary:ASTERISK-07977: Space as the first character of the username part of a uri - valid?
Reporter:Jan Penninkhof (jpenninkhof)Labels:
Date Opened:2006-10-22 17:03:31Date Closed:2006-10-27 01:11:07
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Channels/chan_sip/Interoperability
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:The Cisco 7912g with SIP firmware version 8.0.0 adds a space after 'sip:' in its headers, e.g.: "From: <sip: 002@192.168.1.2;user=phone>;tag=2918293008"

Asterisk doesn't recognize these headers, as it assumes that after the 'sip:' there won't be any spaces.

Please find a full header below:

REGISTER sip:192.168.1.2 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.197:5060;branch=z9hG4bKf58564b2b10867e3
From: <sip: 002@192.168.1.2;user=phone>;tag=2918293008
To: <sip: 002@192.168.1.2;user=phone>
Call-ID: 264923185@192.168.1.197
CSeq: 1 REGISTER
Contact: <sip: 002@192.168.1.197:5060;user=phone;transport=udp>;expires=3600;+sip.instance="<urn:uuid:00000000-0000-0000-0000-000FF7263A42>"
User-Agent: Cisco-CP7912/8.0.0-060111A
Allow: ACK, BYE, CANCEL, INVITE, NOTIFY, OPTIONS, REFER, REGISTER, PRACK, UPDATE
Supported: replaces, 100rel
Content-Length: 0
Comments:By: Olle Johansson (oej) 2006-10-25 06:10:01

Is space a legal character in the first position of the username part of the SIP uri, really?

By: Olle Johansson (oej) 2006-10-25 06:17:42

If it was escaped with URI-encoding, it may be allowed in the "escaped" part of the spec in section 25 of RFC 3261, but not un-encoded. Anyone else that can check the syntax and come with a conclusion if this is a legal SIP uri or not?

By: Jan Penninkhof (jpenninkhof) 2006-10-26 00:14:05

I don't think that Cisco has intended the space to be part of the user-name. I have programmed '002' into the phone, not ' 002'.

It might be a bug in the Cisco firmware (provided that this is indeed bad syntax). But even if it's a bug in the firmware, it would still be great if Asterisk would even support devices with a bit quirky firmware.

By: Olle Johansson (oej) 2006-10-26 01:18:51

If it breaks the RFC, we won't support it - then you have to report a bug to Cisco.
Anything between the colon and the at sign is the username, including the space. If they
add the space, it's obviously a bug you need to report to them.

By: Olle Johansson (oej) 2006-10-26 01:19:20

Not a bug in Asterisk.

By: Jan Penninkhof (jpenninkhof) 2006-10-26 12:40:47

According to rfc-3261, spaces before or after 'tokens' are often allowed. For the colon, space before and after the colon are allowed. It seems that Cisco is applying the protocol according to the rules.

I hope you can reconsider opening this issue-report.

(For more info, please refer to page 220 of http://www.ietf.org/rfc/rfc3261.txt).

By: Olle Johansson (oej) 2006-10-26 13:12:19

Spaces need to be URI-encoded if you read the syntax. In your debug output, it's not.
Check with your web browser - is surfing to

http: // www.asterisk.org

the same as
http://www.asterisk.org

By: Olle Johansson (oej) 2006-10-26 13:13:44

My copy of RFC3261 ends on page 202...

By: Ronald Chan (loloski) 2006-10-26 15:07:38

guys,

i'm not pretending to be an expert here but here what i found on rf3261 page 220, this is a snippet of the full version which can be found here

http://rfclibrary.hosting.com/rfc/rfc3261/rfc3261-220.asp

SIP header field values can be folded onto multiple lines if the
  continuation line begins with a space or horizontal tab.  All linear
  white space, including folding, has the same semantics as SP.  A
  recipient MAY replace any linear white space with a single SP before
  interpreting the field value or forwarding the message downstream.
  This is intended to behave exactly as HTTP/1.1 as described in RFC
  2616 [8].  The SWS construct is used when linear white space is
  optional, generally between tokens and separators.

     LWS  =  [*WSP CRLF] 1*WSP ; linear whitespace
     SWS  =  [LWS] ; sep whitespace

  To separate the header name from the rest of value, a colon is used,
  which, by the above rule, allows whitespace before, but no line
  break, and whitespace after, including a linebreak.  The HCOLON
  defines this construct.

     HCOLON  =  *( SP / HTAB ) ":" SWS

  The TEXT-UTF8 rule is only used for descriptive field contents and
  values that are not intended to be interpreted by the message parser.
  Words of *TEXT-UTF8 contain characters from the UTF-8 charset (RFC
  2279 [7]).  The TEXT-UTF8-TRIM rule is used for descriptive field
  contents that are n t quoted strings, where leading and trailing LWS
  is not meaningful.  In this regard, SIP differs from HTTP, which uses
  the ISO 8859-1 character set.

     TEXT-UTF8-TRIM  =  1*TEXT-UTF8char *(*LWS TEXT-UTF8char)
     TEXT-UTF8char   =  %x21-7E / UTF8-NONASCII
     UTF8-NONASCII   =  %xC0-DF 1UTF8-CONT
                     /  %xE0-EF 2UTF8-CONT
                     /  %xF0-F7 3UTF8-CONT
                     /  %xF8-Fb 4UTF8-CONT
                     /  %xFC-FD 5UTF8-CONT
     UTF8-CONT       =  %x80-BF

--Ronald

By: Olle Johansson (oej) 2006-10-27 01:10:39

This is not a SIP header, it's an URI that follows the SIP RFC and the general rules for URI:s set in another RFC.

Section 2.4.3 of RFC 2396 excludes white space, making it a requirement to URI-encode it. Section 3 does not give any room for whitespace around the colon (:).

As I said, this is a bug in Cisco software. If you did not enter the space as the first character in the user name, it should not be there.