[Home]

Summary:ASTERISK-13244: [patch] SIPAddHeader problems with escaping and quoting
Reporter:John Laur (gork)Labels:
Date Opened:2008-12-18 17:58:33.000-0600Date Closed:2008-12-23 14:56:06.000-0600
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Channels/chan_sip/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) 20081222__bug14110__2.diff.txt
Description:To include semicolons in an argument to SIPAddHeader in extensions.conf they must be escaped. SipAddHeader does not, however, unescape them when adding the header, thus it is impossible to include semicolons in a sip header using extensions.conf. Semicolons are a very important part of many SIP headers that users might want to add with this application.

Additionally, if a double quote is the last character of the argument passed to SIPAddHeader and the entire header is not contained within double quotes, it will not be included in the header.

****** ADDITIONAL INFORMATION ******

exten => 100,1,SIPAddHeader(X-TestHeader: value\;value2)

Header with Current Behavior:

X-TestHeader: value\;value2

Correct Header:

X-TestHeader: value;value2

----------------------------------------

exten => 100,1,SIPAddHeader(Warning: 399 foo.com "This is a test.")

Header with Current Behavior:

Warning: 399 foo.com "This is a test.

Correct Header:

Warning: 399 foo.com "This is a test."
Comments:By: Leif Madsen (lmadsen) 2008-12-22 10:59:45.000-0600

Assigning this issue to Corydon76 as he knows the ins and outs of escaping in the dialplan.

By: John Laur (gork) 2008-12-23 10:25:23.000-0600

Patch seems to work OK however after posting this bug report I had also implemented a workaround that may be much simpler.

It seems there has already been a function implemented to deal with semicolons in the sip headers: ast_unescape_semicolon. This appears to be the only place this function is used. My workaround was simply to do this in sip_addheader (chan_sip.c) instead of passing the unprocessed inbuf:

pbx_builtin_setvar_helper (chan, varbuf, ast_unescape_semicolon(inbuf));

Since you are adding another function to deal with this, wouldn't it make more sense either to reuse the existing one or to replace ast_unescape_semicolon as well? It seems your function may be a little more generic for this purpose, but I don't pretend to understand as much about this business as you guys.

By: Tilghman Lesher (tilghman) 2008-12-23 11:11:36.000-0600

gork:  that function was already in trunk; I merely copied it into 1.6.0.  The main value of that function is that it allows you to enter other characters (such as extended characters) into fields, either with octal or hexadecimal representation.

By: John Laur (gork) 2008-12-23 11:44:10.000-0600

Gotcha; yes it seemed like there was some additional functionality there. Makes sense and looks like it works much better then. I didnt look to see that that function was already in trunk. Thanks for the help. Looks like case closed

By: Mark Michelson (mmichelson) 2008-12-23 12:54:35.000-0600

This is marked "Ready for review" so I took a look at the supplied patch. It looks fine by my eyes. "Ship it!"

By: Digium Subversion (svnbot) 2008-12-23 14:47:41.000-0600

Repository: asterisk
Revision: 166696

U   trunk/channels/chan_sip.c

------------------------------------------------------------------------
r166696 | tilghman | 2008-12-23 14:47:41 -0600 (Tue, 23 Dec 2008) | 7 lines

Allow semicolons and extended characters in user-specified SIP headers.
(closes issue ASTERISK-13244)
Reported by: gork
Patches:
      20081222__bug14110__2.diff.txt uploaded by Corydon76 (license 14)
Tested by: gork, putnopvut

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=166696

By: Digium Subversion (svnbot) 2008-12-23 14:52:15.000-0600

Repository: asterisk
Revision: 166697

_U  branches/1.6.0/
U   branches/1.6.0/channels/chan_sip.c
U   branches/1.6.0/include/asterisk/app.h
U   branches/1.6.0/main/app.c

------------------------------------------------------------------------
r166697 | tilghman | 2008-12-23 14:52:15 -0600 (Tue, 23 Dec 2008) | 14 lines

Merged revisions 166696 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

........
 r166696 | tilghman | 2008-12-23 14:47:08 -0600 (Tue, 23 Dec 2008) | 7 lines
 
 Allow semicolons and extended characters in user-specified SIP headers.
 (closes issue ASTERISK-13244)
  Reported by: gork
  Patches:
        20081222__bug14110__2.diff.txt uploaded by Corydon76 (license 14)
  Tested by: gork, putnopvut
........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=166697

By: Digium Subversion (svnbot) 2008-12-23 14:56:06.000-0600

Repository: asterisk
Revision: 166698

_U  branches/1.6.1/
U   branches/1.6.1/channels/chan_sip.c
U   branches/1.6.1/include/asterisk/app.h
U   branches/1.6.1/main/app.c

------------------------------------------------------------------------
r166698 | tilghman | 2008-12-23 14:56:06 -0600 (Tue, 23 Dec 2008) | 14 lines

Merged revisions 166696 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

........
 r166696 | tilghman | 2008-12-23 14:47:08 -0600 (Tue, 23 Dec 2008) | 7 lines
 
 Allow semicolons and extended characters in user-specified SIP headers.
 (closes issue ASTERISK-13244)
  Reported by: gork
  Patches:
        20081222__bug14110__2.diff.txt uploaded by Corydon76 (license 14)
  Tested by: gork, putnopvut
........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=166698