changeset 1961:3e4c3c8d9a9e

html.cc: Html_tag_open_meta(): check that the URL exists before redirecting.
author Jeremy Henty <onepoint@starurchin.org>
date Thu, 31 Mar 2011 19:02:37 +0100
parents 3d3a1ece7e0f
children 9cce482083ef
files src/html.cc
diffstat 1 files changed, 37 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/src/html.cc	Sun Mar 27 10:16:51 2011 +0100
+++ b/src/html.cc	Thu Mar 31 19:02:37 2011 +0100
@@ -2866,42 +2866,45 @@
          }
          /* Skip to anything after "URL=" */
          while (*content && *(content++) != '=') ;
-         /* Handle the case of a quoted URL */
-         if (*content == '"' || *content == '\'') {
-            if ((p = strchr(content + 1, *content)))
-               mr_url = dStrndup(content + 1, p - content - 1);
-            else
-               mr_url = dStrdup(content + 1);
-         } else {
-            mr_url = dStrdup(content);
+         if (*content) {
+
+            /* Handle the case of a quoted URL */
+            if (*content == '"' || *content == '\'') {
+               if ((p = strchr(content + 1, *content)))
+                  mr_url = dStrndup(content + 1, p - content - 1);
+               else
+                  mr_url = dStrdup(content + 1);
+            } else {
+               mr_url = dStrdup(content);
+            }
+
+            if (delay == 0) {
+               /* zero-delay redirection */
+               html->stop_parser = true;
+               DilloUrl *new_url = a_Url_new(mr_url, URL_STR(html->base_url));
+               if (a_Capi_dpi_verify_request(html->bw, new_url))
+                  a_UIcmd_redirection0((void*)html->bw, new_url);
+               a_Url_free(new_url);
+            } else {
+               /* Send a custom HTML message.
+                * TODO: This is a hairy hack,
+                *       It'd be much better to build a widget. */
+               Dstr *ds_msg = dStr_sized_new(256);
+               dStr_sprintf(ds_msg, meta_template, mr_url, delay_str);
+               {
+                  int o_InFlags = html->InFlags;
+                  int o_TagSoup = html->TagSoup;
+                  html->InFlags = IN_BODY;
+                  html->TagSoup = false;
+                  Html_write_raw(html, ds_msg->str, ds_msg->len, 0);
+                  html->TagSoup = o_TagSoup;
+                  html->InFlags = o_InFlags;
+               }
+               dStr_free(ds_msg, 1);
+            }
+            dFree(mr_url);
          }
 
-         if (delay == 0) {
-            /* zero-delay redirection */
-            html->stop_parser = true;
-            DilloUrl *new_url = a_Url_new(mr_url, URL_STR(html->base_url));
-            if (a_Capi_dpi_verify_request(html->bw, new_url))
-               a_UIcmd_redirection0((void*)html->bw, new_url);
-            a_Url_free(new_url);
-         } else {
-            /* Send a custom HTML message.
-             * TODO: This is a hairy hack,
-             *       It'd be much better to build a widget. */
-            Dstr *ds_msg = dStr_sized_new(256);
-            dStr_sprintf(ds_msg, meta_template, mr_url, delay_str);
-            {
-               int o_InFlags = html->InFlags;
-               int o_TagSoup = html->TagSoup;
-               html->InFlags = IN_BODY;
-               html->TagSoup = false;
-               Html_write_raw(html, ds_msg->str, ds_msg->len, 0);
-               html->TagSoup = o_TagSoup;
-               html->InFlags = o_InFlags;
-            }
-            dStr_free(ds_msg, 1);
-         }
-         dFree(mr_url);
-
       } else if (!dStrcasecmp(equiv, "content-type") &&
                  (content = a_Html_get_attr(html, tag, tagsize, "content"))) {
          _MSG("Html_tag_open_meta: content={%s}\n", content);