changeset 1958:7860a3051241

Fix for endless loop with META refresh and same URL or no URL at all
author Jorge Arellano Cid <jcid@dillo.org>
date Fri, 15 Apr 2011 14:08:53 -0300
parents 2ac2b0e6aced
children 648b1506e9aa
files src/html.cc
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/html.cc	Fri Apr 01 14:59:23 2011 -0300
+++ b/src/html.cc	Fri Apr 15 14:08:53 2011 -0300
@@ -2845,6 +2845,7 @@
 
    const char *p, *equiv, *content, *new_content;
    char delay_str[64], *mr_url;
+   DilloUrl *new_url;
    int delay;
 
    /* only valid inside HEAD */
@@ -2875,14 +2876,17 @@
          } else {
             mr_url = dStrdup(content);
          }
-
-         if (delay == 0) {
+         new_url = a_Url_new(mr_url, URL_STR(html->base_url));
+
+         if (a_Url_cmp(html->base_url, new_url) == 0) {
+            /* redirection loop, or empty url string: ignore */
+            BUG_MSG("META refresh: %s\n", 
+                    *mr_url ? "redirection loop" : "no target URL");
+         } else 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,
@@ -2900,6 +2904,7 @@
             }
             dStr_free(ds_msg, 1);
          }
+         a_Url_free(new_url);
          dFree(mr_url);
 
       } else if (!dStrcasecmp(equiv, "content-type") &&