Commit e240481b authored by jehan's avatar jehan

fix message parser for headers with CRLF SP sequence

parent 5763f61e
......@@ -483,8 +483,8 @@ BELLE_SIP_END_DECLS
#if defined(__cplusplus) && defined(BELLE_SIP_USE_STL)
#include <ostream>
inline ostream&
operator<<( ostream& __os, const belle_sip_object_t* object)
inline std::ostream&
operator<<( std::ostream& __os, const belle_sip_object_t* object)
{
char* object_as_string = belle_sip_object_to_string((void*)object);
__os << object_as_string;
......
......@@ -222,8 +222,8 @@ BELLE_SIP_END_DECLS
#if defined(__cplusplus) && defined(BELLE_SIP_USE_STL)
#include <ostream>
inline ostream&
operator<<( ostream& __os, const belle_sip_uri_t* uri)
inline std::ostream&
operator<<( std::ostream& __os, const belle_sip_uri_t* uri)
{
char* uri_as_string = belle_sip_uri_to_string(uri);
__os << uri_as_string;
......
......@@ -1373,7 +1373,7 @@ header_name
header_value[const char* name, ANTLR3_BOOLEAN is_http] returns [belle_sip_header_t* ret]
options { greedy = false; }
@init {$ret=NULL;}
: (~(SP|CRLF) ~(CRLF)* ) {
: (~(SP|CRLF) ((CRLF SP) | ~CRLF)* ) {
if ($is_http) {
$ret=belle_http_header_create($name,(const char*)$header_value.text->chars);
}else {
......
......@@ -489,10 +489,14 @@ static void check_header_authenticate(belle_sip_header_www_authenticate_t* authe
static void test_www_authenticate_header(void) {
const char* l_header = "WWW-Authenticate: Digest "
"algorithm=MD5, realm=\"atlanta.com\", opaque=\"1bc7f9097684320\","
"algorithm=MD5,\r\n realm=\"atlanta.com\",\r\n opaque=\"1bc7f9097684320\","
" qop=\"auth,auth-int\", nonce=\"c60f3082ee1212b402a21831ae\", stale=true, domain=\"sip:boxesbybob.com\"";
const char* l_header_1 = "WWW-Authenticate: Digest realm=\"toto.com\",\r\n nonce=\"b543409177c9036dbf3054aea940e9703dc8f84c0108\""
",\r\n opaque=\"ALU:QbkRBthOEgEQAkgVEwwHRAIBHgkdHwQCQ1lFRkRWEAkic203MSEzJCgoZS8iI3VlYWRj\",\r\n algorithm=MD5"
",\r\n qop=\"auth\"";
belle_sip_header_www_authenticate_t* L_tmp;
belle_sip_header_www_authenticate_t* l_authenticate = belle_sip_header_www_authenticate_parse(l_header);
belle_sip_header_www_authenticate_t *l_authenticate = belle_sip_header_www_authenticate_parse(l_header);
char* l_raw_header = belle_sip_object_to_string(BELLE_SIP_OBJECT(l_authenticate));
......@@ -502,6 +506,15 @@ static void test_www_authenticate_header(void) {
belle_sip_object_unref(BELLE_SIP_OBJECT(L_tmp));
belle_sip_free(l_raw_header);
check_header_authenticate(l_authenticate);
l_authenticate = belle_sip_header_www_authenticate_parse(l_header_1);
l_raw_header = belle_sip_object_to_string(BELLE_SIP_OBJECT(l_authenticate));
belle_sip_object_unref(BELLE_SIP_OBJECT(l_authenticate));
L_tmp = belle_sip_header_www_authenticate_parse(l_raw_header);
l_authenticate = BELLE_SIP_HEADER_WWW_AUTHENTICATE(belle_sip_object_clone(BELLE_SIP_OBJECT(L_tmp)));
belle_sip_object_unref(BELLE_SIP_OBJECT(l_authenticate));
CU_ASSERT_PTR_NULL(belle_sip_header_www_authenticate_parse("nimportequoi"));
}
......
......@@ -152,7 +152,7 @@ static void test401ResponseWithoutResponsePhrase(void) {
"Server: Cirpack/v4.42x (gw_sip)\r\n"
"To: <sip:0033482176@sip.ovh.net>;tag=00-08075-24212984-22e348d97\r\n"
"Via: SIP/2.0/UDP 192.168.0.18:5062;received=81.56.113.2;rport=5062;branch=z9hG4bK1939354046\r\n"
"WWW-Authenticate: Digest realm=\"sip.ovh.net\",nonce=\"24212965507cde726e8bc37e04686459\",opaque=\"241b9fb347752f2\",stale=false,algorithm=MD5\r\n"
"WWW-Authenticate: Digest realm=\"sip.ovh.net\",\r\n nonce=\"24212965507cde726e8bc37e04686459\",opaque=\"241b9fb347752f2\",stale=false,algorithm=MD5\r\n"
"Content-Length: 0\r\n\r\n";
belle_sip_response_t* response;
belle_sip_message_t* message = belle_sip_message_parse(raw_message);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment