Commit c94f3b28 authored by jehan's avatar jehan

really fix http path with / only

parent bf66a3a3
......@@ -942,7 +942,7 @@ belle_sip_header_extension_t* belle_sip_header_extension_parse (const char* valu
lex = belle_sip_messageLexerNew (input);
tokens = antlr3CommonTokenStreamSourceNew (1025, lex->pLexer->rec->state->tokSource);
parser = belle_sip_messageParserNew (tokens);
l_parsed_object = parser->header_extension(parser,FALSE);
l_parsed_object = parser->header_extension(parser,FALSE,FALSE);
parser ->free(parser);
tokens ->free(tokens);
lex ->free(lex);
......
......@@ -103,10 +103,14 @@ belle_sip_error_code belle_generic_uri_marshal(const belle_generic_uri_t* uri, c
}
if (uri->path) {
char* escaped_path=belle_generic_uri_to_escaped_path(uri->path);
error=belle_sip_snprintf(buff,buff_size,offset,"/%s",escaped_path);
belle_sip_free(escaped_path);
error=belle_sip_snprintf(buff,buff_size,offset,"/",NULL);
if (error!=BELLE_SIP_OK) return error;
if (*(uri->path+1) != '\0') { /*+1 to skip leading /*/
char* escaped_path=belle_generic_uri_to_escaped_path(uri->path+1);
error=belle_sip_snprintf(buff,buff_size,offset,"%s",escaped_path);
belle_sip_free(escaped_path);
if (error!=BELLE_SIP_OK) return error;
}
}
if (uri->query) {
......
......@@ -12,7 +12,7 @@ nodist_libbellesip_generated_la_SOURCES= \
.NOTPARALLEL $(builddir)/belle_sip_messageParser.c $(builddir)/belle_sip_messageParser.h \
$(builddir)/belle_sip_messageLexer.c $(builddir)/belle_sip_messageLexer.h : belle_sip_message.g
$(ANTLR) -make -Xmultithreaded -fo $(builddir) $(srcdir)/belle_sip_message.g
$(ANTLR) -make -Xmultithreaded -fo $(builddir) $(srcdir)/belle_sip_message.g
.NOTPARALLEL $(builddir)/belle_sdpLexer.c \
$(builddir)/belle_sdpParser.c \
......
......@@ -181,7 +181,7 @@ message_header [belle_sip_message_t* message]
// | header_via {belle_sip_message_add_header(message,BELLE_SIP_HEADER($header_via.ret));}/*
// | warning
// | www_authenticate*/
header_extension[TRUE] {
header_extension[TRUE,(BELLE_SIP_OBJECT_IS_INSTANCE_OF($message,belle_http_resquest_t) ||BELLE_SIP_OBJECT_IS_INSTANCE_OF($message,belle_http_response_t)) ] {
belle_sip_header_t* lheader = BELLE_SIP_HEADER($header_extension.ret);
do {
if (lheader == NULL) break; /*sanity check*/
......@@ -304,9 +304,9 @@ catch [ANTLR3_MISMATCHED_TOKEN_EXCEPTION]
hier_part[belle_generic_uri_t* uri] returns [belle_generic_uri_t* ret=NULL]
: (
(SLASH SLASH)=>( SLASH SLASH authority[uri] (SLASH path_segments[uri])?)
(SLASH SLASH)=>( SLASH SLASH authority[uri] (path_segments[uri])?)
|
(SLASH path_segments[uri]) )
( path_segments[uri]) )
(QMARK query
{
char* unescaped_query;
......@@ -316,14 +316,14 @@ hier_part[belle_generic_uri_t* uri] returns [belle_generic_uri_t* ret=NULL]
}) ?;
path_segments[belle_generic_uri_t* uri]
: (segment? ( SLASH segment )*)
: SLASH (segment ( SLASH segment )*)
{
char* unescaped_path;
unescaped_path=belle_sip_to_unescaped_string((const char *)$path_segments.text->chars);
belle_generic_uri_set_path(uri,(const char*)unescaped_path);
belle_sip_free(unescaped_path);
};
segment: pchar+ ( SEMI param )*;
segment: pchar* ( SEMI param )*;
param: pchar*;
pchar: unreserved | escaped | COLON | AT | AND | EQUAL | PLUS | DOLLARD | COMMA;
......@@ -1361,7 +1361,7 @@ privacy_val: token {belle_sip_header_privacy_add_privacy($header_privacy::curren
//********************************************************************************************//
header_extension[ANTLR3_BOOLEAN check_for_known_header] returns [belle_sip_header_t* ret]
header_extension[ANTLR3_BOOLEAN check_for_known_header,ANTLR3_BOOLEAN is_http] returns [belle_sip_header_t* ret]
scope {int as_value;}
@init {$header_extension::as_value=0;}
: (header_name
......@@ -1399,7 +1399,7 @@ scope {int as_value;}
$ret = BELLE_SIP_HEADER(belle_sip_header_max_forwards_parse((const char*)$header_extension.text->chars));
} else if (check_for_known_header && strcasecmp("User-Agent",(const char*)$header_name.text->chars) == 0) {
$ret = BELLE_SIP_HEADER(belle_sip_header_user_agent_parse((const char*)$header_extension.text->chars));
} else if (check_for_known_header && strcasecmp("Expires",(const char*)$header_name.text->chars) == 0) {
} else if (check_for_known_header && !is_http && strcasecmp("Expires",(const char*)$header_name.text->chars) == 0) {
$ret = BELLE_SIP_HEADER(belle_sip_header_expires_parse((const char*)$header_extension.text->chars));
} else if (check_for_known_header && strcasecmp("Allow",(const char*)$header_name.text->chars) == 0) {
$ret = BELLE_SIP_HEADER(belle_sip_header_allow_parse((const char*)$header_extension.text->chars));
......
......@@ -33,7 +33,7 @@ static void test_basic_uri() {
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_scheme(uri),"http");
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_host(uri),"www.linphone.org");
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_path(uri),"index.html");
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_path(uri),"/index.html");
belle_sip_object_unref(uri);
......@@ -53,7 +53,7 @@ static void test_complex_uri() {
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_user(uri),"toto");
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_user_password(uri),"secret");
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_host(uri),"ftp.linphone.fr");
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_path(uri),"url");
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_path(uri),"/url");
CU_ASSERT_EQUAL(belle_generic_uri_get_port(uri),1234);
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_query(uri),"sa=t&rct=j&url=http://translate.google.fr");
......@@ -71,7 +71,7 @@ static void test_abs_path() {
CU_ASSERT_PTR_NULL(belle_generic_uri_get_scheme(uri));
CU_ASSERT_PTR_NULL(belle_generic_uri_get_host(uri));
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_path(uri),"index.html");
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_path(uri),"/index.html");
}
......
......@@ -590,7 +590,7 @@ static void testHttpGet(void) {
http_request=BELLE_HTTP_REQUEST(msg);
CU_ASSERT_PTR_NOT_NULL_FATAL(uri=belle_http_request_get_uri(http_request));
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_path(uri),"index.php");
CU_ASSERT_STRING_EQUAL(belle_generic_uri_get_path(uri),"/index.php");
CU_ASSERT_PTR_NOT_NULL(belle_sip_message_get_header(msg,"User-Agent"));
CU_ASSERT_PTR_NOT_NULL(belle_sip_message_get_header(msg,"Accept"));
CU_ASSERT_PTR_NOT_NULL(belle_sip_message_get_header(msg,"Connection"));
......
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