Mercurial > pidgin
comparison src/html.c @ 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 | 0241d6b6702d |
| children | d64bbc7ab746 |
comparison
equal
deleted
inserted
replaced
| 5500:9cc2f0f20d87 | 5501:36d2c875a822 |
|---|---|
| 89 return text2; | 89 return text2; |
| 90 } | 90 } |
| 91 | 91 |
| 92 struct g_url *parse_url(char *url) | 92 struct g_url *parse_url(char *url) |
| 93 { | 93 { |
| 94 struct g_url *test = g_new0(struct g_url, 1); | 94 struct g_url *test = (struct g_url*)malloc(sizeof(struct g_url)); |
| 95 char scan_info[255]; | 95 char scan_info[255]; |
| 96 char port[5]; | 96 char port[5]; |
| 97 int f; | 97 int f; |
| 98 | 98 char* turl; |
| 99 if (strstr(url, "http://")) | 99 /* hyphen at end includes it in control set */ |
| 100 g_snprintf(scan_info, sizeof(scan_info), | 100 char addr_ctrl[] = "A-Za-z0-9.-"; |
| 101 "http://%%[A-Za-z0-9.]:%%[0-9]/%%[A-Za-z0-9.~_-/&%%?=+]"); | 101 char port_ctrl[] = "0-9"; |
| 102 else | 102 char page_ctrl[] = "A-Za-z0-9.~_/&%%?=+^-"; |
| 103 g_snprintf(scan_info, sizeof(scan_info), | 103 |
| 104 "%%[A-Za-z0-9.]:%%[0-9]/%%[A-Za-z0-9.~_-/&%%?=+^]"); | 104 if((turl=strstr(url, "http://")) || (turl=strstr(url, "HTTP://"))) |
| 105 url=turl+=7; | |
| 106 | |
| 107 snprintf(scan_info, sizeof(scan_info), | |
| 108 "%%[%s]:%%[%s]/%%[%s]", | |
| 109 addr_ctrl, port_ctrl, page_ctrl); | |
| 110 | |
| 105 f = sscanf(url, scan_info, test->address, port, test->page); | 111 f = sscanf(url, scan_info, test->address, port, test->page); |
| 106 if (f == 1) { | 112 if (f == 1) { |
| 107 if (strstr(url, "http://")) | 113 snprintf(scan_info, sizeof(scan_info), |
| 108 g_snprintf(scan_info, sizeof(scan_info), | 114 "%%[%s]/%%[%s]", |
| 109 "http://%%[A-Za-z0-9.]/%%[A-Za-z0-9.~_-/&%%?=+^]"); | 115 addr_ctrl, page_ctrl); |
| 110 else | |
| 111 g_snprintf(scan_info, sizeof(scan_info), | |
| 112 "%%[A-Za-z0-9.]/%%[A-Za-z0-9.~_-/&%%?=+^]"); | |
| 113 f = sscanf(url, scan_info, test->address, test->page); | 116 f = sscanf(url, scan_info, test->address, test->page); |
| 114 g_snprintf(port, sizeof(test->port), "80"); | 117 snprintf(port, sizeof(port), "80"); |
| 115 port[2] = 0; | 118 } |
| 116 } | 119 if (f == 1) |
| 117 if (f == 1) { | 120 snprintf(test->page, sizeof(test->page), ""); |
| 118 if (strstr(url, "http://")) | |
| 119 g_snprintf(scan_info, sizeof(scan_info), "http://%%[A-Za-z0-9.]"); | |
| 120 else | |
| 121 g_snprintf(scan_info, sizeof(scan_info), "%%[A-Za-z0-9.]"); | |
| 122 f = sscanf(url, scan_info, test->address); | |
| 123 g_snprintf(test->page, sizeof(test->page), "%c", '\0'); | |
| 124 } | |
| 125 | 121 |
| 126 sscanf(port, "%d", &test->port); | 122 sscanf(port, "%d", &test->port); |
| 127 return test; | 123 return test; |
| 128 } | 124 } |
| 129 | 125 |
