Mercurial > pidgin
changeset 5501:36d2c875a822
[gaim-migrate @ 5900]
Cleanup and fix for parse_url, which was breaking page strings with hyphens on win32
committer: Tailor Script <tailor@pidgin.im>
author | Herman Bloggs <hermanator12002@yahoo.com> |
---|---|
date | Fri, 23 May 2003 17:23:14 +0000 |
parents | 9cc2f0f20d87 |
children | a6c08c86bf7f |
files | src/html.c |
diffstat | 1 files changed, 19 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/src/html.c Fri May 23 04:24:58 2003 +0000 +++ b/src/html.c Fri May 23 17:23:14 2003 +0000 @@ -91,37 +91,33 @@ struct g_url *parse_url(char *url) { - struct g_url *test = g_new0(struct g_url, 1); + struct g_url *test = (struct g_url*)malloc(sizeof(struct g_url)); char scan_info[255]; char port[5]; int f; + char* turl; + /* hyphen at end includes it in control set */ + char addr_ctrl[] = "A-Za-z0-9.-"; + char port_ctrl[] = "0-9"; + char page_ctrl[] = "A-Za-z0-9.~_/&%%?=+^-"; - if (strstr(url, "http://")) - g_snprintf(scan_info, sizeof(scan_info), - "http://%%[A-Za-z0-9.]:%%[0-9]/%%[A-Za-z0-9.~_-/&%%?=+]"); - else - g_snprintf(scan_info, sizeof(scan_info), - "%%[A-Za-z0-9.]:%%[0-9]/%%[A-Za-z0-9.~_-/&%%?=+^]"); + if((turl=strstr(url, "http://")) || (turl=strstr(url, "HTTP://"))) + url=turl+=7; + + snprintf(scan_info, sizeof(scan_info), + "%%[%s]:%%[%s]/%%[%s]", + addr_ctrl, port_ctrl, page_ctrl); + f = sscanf(url, scan_info, test->address, port, test->page); if (f == 1) { - if (strstr(url, "http://")) - g_snprintf(scan_info, sizeof(scan_info), - "http://%%[A-Za-z0-9.]/%%[A-Za-z0-9.~_-/&%%?=+^]"); - else - g_snprintf(scan_info, sizeof(scan_info), - "%%[A-Za-z0-9.]/%%[A-Za-z0-9.~_-/&%%?=+^]"); + snprintf(scan_info, sizeof(scan_info), + "%%[%s]/%%[%s]", + addr_ctrl, page_ctrl); f = sscanf(url, scan_info, test->address, test->page); - g_snprintf(port, sizeof(test->port), "80"); - port[2] = 0; + snprintf(port, sizeof(port), "80"); } - if (f == 1) { - if (strstr(url, "http://")) - g_snprintf(scan_info, sizeof(scan_info), "http://%%[A-Za-z0-9.]"); - else - g_snprintf(scan_info, sizeof(scan_info), "%%[A-Za-z0-9.]"); - f = sscanf(url, scan_info, test->address); - g_snprintf(test->page, sizeof(test->page), "%c", '\0'); - } + if (f == 1) + snprintf(test->page, sizeof(test->page), ""); sscanf(port, "%d", &test->port); return test;