asterisk/tests
David Vossel d16b89be17 RFC compliant uri and display-name encode/decode
1.  URI Encoding
This patch changes ast_uri_encode()'s behavior when doreserved is enabled.
Previously when doreserved was enabled only a small set of reserved
characters were encoded.  This set was comprised primarily of the reserved
characters defined in RFC3261 section 25.1, but contained other characters as
well.  Rather than only escaping the reserved set, doreserved now escapes
all characters not within the unreserved set as defined by RFC 3261 and
RFC 2396.  Also, the 'doreserved' variable has been renamed to 'do_special_char'
in attempts to avoid confusion.

When doreserve is not enabled, the previous logic of only encoding the
characters <= 0X1F and > 0X7f remains, except for the '%' character, which
must always be encoded as it signifies a HEX escaped character during the decode
process.

2. URI Decoding: Break up URI before decode.
In chan_sip.c ast_uri_decode is called on the entire URI instead of it's
individual parts after it is parsed.  This is not good as ast_uri_decode
can introduce special characters back into the URI which can mess up parsing.
This patch resolves this by not decoding a URI until parsing is completely
done.  There are many instances where we check to see if pedantic checking
is enabled before we decode a URI.  In these cases a new macro,
SIP_PEDANTIC_DECODE, is used on the individual parsed segments of the URI
rather than constantly putting if (pedantic) { decode() } checks everywhere
in the code.  In the areas where ast_uri_decode is not dependent upon
pedantic checking this macro is not used, but decoding is still moved to
each individual part of the URI.  The only behavior that should change from
this patch is the time at which decoding occurs.

Since I had to look over every place URI parsing occurs to create this
patch, I found several places where we use duplicate code for parsing.
To consolidate the code, those areas have updated to use the parse_uri()
function where possible.

3. SIP display-name decoding according to RFC3261 section 25.
To properly decode the display-name portion of a FROM header, chan_sip's
get_calleridname() function required a complete re-write.  More information
about this change can be found in the comments at the beginning of this function.

4. Unit Tests.
Unit tests for ast_uri_encode, ast_uri_decode, and get_calleridname() have been
written.  This involved the addition of the test_utils.c file for testing the
utils api.

(closes issue #16299)
Reported by: wdoekes
Patches:
      astsvn-16299-get_calleridname.diff uploaded by wdoekes (license 717)
      get_calleridname_rewrite.diff uploaded by dvossel (license 671)
Tested by: wdoekes, dvossel, Nick_Lewis

Review: https://reviewboard.asterisk.org/r/469/



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@243200 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2010-01-26 16:30:08 +00:00
..
Makefile add some simple infrastructure for modules to be used for testing parts of Asterisk 2008-01-03 20:04:30 +00:00
test_ami_security_events.sh Add an API for reporting security events, and a security event logging module. 2009-07-11 19:15:03 +00:00
test_amihooks.c ami_testhooks.c automatically registers hook 2009-11-06 22:07:22 +00:00
test_ast_format_str_reduce.c Make unit test modules depend on TEST_FRAMEWORK instead of off by default. 2010-01-25 21:32:38 +00:00
test_dlinklists.c Introducing doubly linked lists to trunk from branch team/murf/bug11210. 2008-04-16 17:14:18 +00:00
test_heap.c Make unit test modules depend on TEST_FRAMEWORK instead of off by default. 2010-01-25 21:32:38 +00:00
test_logger.c Add ability for modules to dynamically register logger levels 2009-05-15 13:13:47 +00:00
test_sched.c Make unit test modules depend on TEST_FRAMEWORK instead of off by default. 2010-01-25 21:32:38 +00:00
test_security_events.c Add an API for reporting security events, and a security event logging module. 2009-07-11 19:15:03 +00:00
test_skel.c Make unit test modules depend on TEST_FRAMEWORK instead of off by default. 2010-01-25 21:32:38 +00:00
test_substitution.c Log the variable name being tested. 2010-01-26 15:46:53 +00:00
test_utils.c RFC compliant uri and display-name encode/decode 2010-01-26 16:30:08 +00:00