Changeset 3332
- Timestamp:
- Oct 1, 2010 6:43:17 AM (14 years ago)
- Location:
- pjproject/trunk/pjlib-util/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib-util/src/pjlib-util-test/http_client.c
r3321 r3332 304 304 {"http://:@pjsip.org", PJ_SUCCESS, "", "", "pjsip.org", 80, "/"}, 305 305 306 /* '@' character in username and path */ 307 {"http://user@pjsip.org/@", PJ_SUCCESS, "user", "", "pjsip.org", 80, "/@"}, 308 309 /* '@' character in path */ 310 {"http://pjsip.org/@", PJ_SUCCESS, "", "", "pjsip.org", 80, "/@"}, 311 312 /* '@' character in path */ 313 {"http://pjsip.org/one@", PJ_SUCCESS, "", "", "pjsip.org", 80, "/one@"}, 314 306 315 /* Invalid URL */ 307 316 {"http://:", PJ_EINVAL, "", "", "", 0, ""}, … … 324 333 /* Invalid URL */ 325 334 {"http://@/", PJ_EINVAL, "", "", "", 0, ""}, 335 336 /* Invalid URL */ 337 {"http:///@", PJ_EINVAL, "", "", "", 0, ""}, 326 338 327 339 /* Invalid URL */ -
pjproject/trunk/pjlib-util/src/pjlib-util/http_client.c
r3321 r3332 767 767 } 768 768 769 /* Get the location of '@' character to indicate the end of 770 * user:passwd part of an URI. If user:passwd part is not 771 * present, NULL will be returned. 772 */ 773 static char *get_url_at_pos(const char *str, long len) 774 { 775 const char *end = str + len; 776 const char *p = str; 777 778 /* skip scheme: */ 779 while (p!=end && *p!='/') ++p; 780 if (p!=end && *p=='/') ++p; 781 if (p!=end && *p=='/') ++p; 782 if (p==end) return NULL; 783 784 for (; p!=end; ++p) { 785 switch (*p) { 786 case '/': 787 return NULL; 788 case '@': 789 return (char*)p; 790 } 791 } 792 793 return NULL; 794 } 795 796 769 797 PJ_DEF(pj_status_t) pj_http_req_parse_url(const pj_str_t *url, 770 798 pj_http_url *hurl) … … 802 830 pj_scan_advance_n(&scanner, 3, PJ_FALSE); 803 831 804 if ( pj_memchr(url->ptr, '@', url->slen)) {832 if (get_url_at_pos(url->ptr, url->slen)) { 805 833 /* Parse username and password */ 806 834 pj_scan_get_until_chr(&scanner, ":@", &hurl->username); … … 925 953 * remove them from the URL. 926 954 */ 927 if ((at_pos= pj_strchr(&hreq->url, '@')) != NULL) {955 if ((at_pos=get_url_at_pos(hreq->url.ptr, hreq->url.slen)) != NULL) { 928 956 pj_str_t tmp; 929 957 char *user_pos = pj_strchr(&hreq->url, '/');
Note: See TracChangeset
for help on using the changeset viewer.