r3229 jmb - /trunk/netsurf/render/html.c
by netsurf@semichrome.net
Author: jmb
Date: Sun Apr 1 17:41:22 2007
New Revision: 3229
URL: http://svn.semichrome.net?rev=3229&view=rev
Log:
Deal with more ways in which meta refresh URLs can be invalid.
Modified:
trunk/netsurf/render/html.c
Modified: trunk/netsurf/render/html.c
URL: http://svn.semichrome.net/trunk/netsurf/render/html.c?rev=3229&r1=3228&r2...
==============================================================================
--- trunk/netsurf/render/html.c (original)
+++ trunk/netsurf/render/html.c Sun Apr 1 17:41:22 2007
@@ -61,7 +61,7 @@
static const char empty_document[] =
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\""
- " \"http://www.w3.org/TR/html4/strict.dtd\">"
+ " \"http://www.w3.org/TR/html4/strict.dtd\">"
"<html>"
"<head>"
"<title>Empty document</title>"
@@ -575,22 +575,32 @@
}
for ( ; url <= end - 4; url++) {
- if (!strncasecmp(url, "url=", 4))
+ if (!strncasecmp(url, "url=", 4)) {
+ url += 4;
break;
- }
-
- /* mail.google.com sends out the broken format "<n>, url='<url>'", so
- * special case this */
- if (url <= end - 4) {
- if ((url[4] == '\'') && (end[-1] == '\'')) {
- *--end = '\0';
- url++;
- }
- }
-
- if (url <= end - 4) {
- res = url_join(url + 4, c->data.html.base_url,
- &refresh);
+ }
+ }
+
+ /* various sites contain junk meta refresh URL components,
+ * so attempt to deal with this by stripping likely garbage
+ * from the beginning and end of URLs */
+ while (url < end) {
+ if (isspace(*url) || *url == '\'' || *url == '"')
+ url++;
+ else
+ break;
+ }
+
+ while (end > url) {
+ if (isspace(end[-1]) || end[-1] == '\'' ||
+ end[-1] == '"')
+ *--end = '\0';
+ else
+ break;
+ }
+
+ if (url < end) {
+ res = url_join(url, c->data.html.base_url, &refresh);
xmlFree(content);
@@ -599,8 +609,7 @@
content_broadcast(c,
CONTENT_MSG_ERROR, msg_data);
return false;
- }
- else if (res == URL_FUNC_FAILED) {
+ } else if (res == URL_FUNC_FAILED) {
/* This isn't fatal so carry on looking */
continue;
}
15 years, 10 months