url.c: _url_d() accepts unescaped # in userpart of sip/sips uri

darcs-hash:20070122150838-3ff9f-061f703ed72b2625ac198bc43d7062eb31551ffa.gz
parent f8b90427
......@@ -333,6 +333,10 @@ int test_sip(void)
TEST_P(url_hdup(home, (url_t*)"sip:test@127.0.0.1:55:"), NULL);
TEST_P(url_hdup(home, (url_t*)"sip:test@127.0.0.1:sip"), NULL);
u = url_hdup(home, (url_t*)"SIP:#**00**#;foo=/bar@127.0.0.1"); TEST_1(u);
TEST(u->url_type, url_sip);
TEST_S(u->url_user, "#**00**#;foo=/bar");
for (i = 32; i <= 256; i++) {
char pu[512];
char param[512];
......
......@@ -555,7 +555,7 @@ enum url_type_e url_get_type(char const *scheme, size_t len)
static
int _url_d(url_t *url, char *s)
{
size_t n;
size_t n, p;
char *s0, rest_c, *host;
int net_path = 1;
......@@ -592,9 +592,15 @@ int _url_d(url_t *url, char *s)
if (url->url_type == url_sip || url->url_type == url_sips) {
/* SIP URL may have /; in user part */
n = strcspn(s, "@#"); /* Opaque part */
if (s[n] != '@')
n = 0;
/* Some #*@#* phones include unescaped # there, too */
n = strcspn(s, "@#"); /* Opaque part */
if (s[n] == '#') {
p = strcspn(s + n + 1, "@") + 1;
if (s[n + p] == '@')
n += p;
else
n = 0;
}
n += strcspn(s + n, "/;?#");
}
else if (url->url_type == url_wv) {
......
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