1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-29 03:17:53 -04:00

Let be more tolerant with buggy meta refresh. It should fix bug 767.

This commit is contained in:
Laurent MONIN 2006-07-10 21:16:14 +02:00 committed by Laurent MONIN
parent 442645b766
commit 36a277540c

View File

@ -262,6 +262,36 @@ html_skip(struct html_context *html_context, unsigned char *a)
html_top->type = ELEMENT_DONT_KILL;
}
/* Parse meta refresh without URL= in it:
* <meta http-equiv="refresh" content="3,http://elinks.or.cz/">
* <meta http-equiv="refresh" content="3; http://elinks.or.cz/">
* <meta http-equiv="refresh" content=" 3 ; http://elinks.or.cz/ ">
*/
static void
parse_old_meta_refresh(unsigned char *str, unsigned char **ret)
{
unsigned char *p = str;
int len;
assert(str && ret);
if_assert_failed return;
*ret = NULL;
while (*p && (*p == ' ' || *p == ASCII_TAB)) p++;
if (!*p) return;
while (*p && *p >= '0' && *p <= '9') p++;
if (!*p) return;
while (*p && (*p == ' ' || *p == ASCII_TAB)) p++;
if (!*p) return;
if (*p == ';' || *p == ',') p++; else return;
while (*p && (*p == ' ' || *p == ASCII_TAB)) p++;
if (!*p) return;
len = strlen(p);
while (len && (p[len] == ' ' || p[len] == ASCII_TAB)) len--;
if (len) *ret = memacpy(p, len);
}
void
process_head(struct html_context *html_context, unsigned char *head)
{
@ -272,9 +302,13 @@ process_head(struct html_context *html_context, unsigned char *head)
parse_header_param(refresh, "URL", &url);
if (!url) {
/* If the URL parameter is missing assume that the
* document being processed should be refreshed. */
url = get_uri_string(html_context->base_href, URI_ORIGINAL);
/* Let's try a more tolerant parsing. */
parse_old_meta_refresh(refresh, &url);
if (!url) {
/* If the URL parameter is missing assume that the
* document being processed should be refreshed. */
url = get_uri_string(html_context->base_href, URI_ORIGINAL);
}
}
if (url) {