Re: Fwd: Bug#642391: dillo: sane default for http redirects [origin: [email protected]]
"corvid" <[email protected]>
| Newsgroups | gmane.comp.web.dillo.devel |
|---|---|
| Message-ID | <20110922131355.GC18148@local> |
Axel wrote: > One easy way to do so would to display the content of the redirect > page which usually contains a link to the redirect target. That's an interesting idea! I should be sleeping, but how does the attached work for you? _______________________________________________ Dillo-dev mailing list [email protected] http://lists.auriga.wearlab.de/cgi-bin/mailman/listinfo/dillo-dev
redirection.diff
(text/plain, 2.6 KB)
diff -r 538f207b9077 src/cache.c
--- a/src/cache.c Wed Sep 21 19:34:48 2011 +0200
+++ b/src/cache.c Thu Sep 22 13:04:36 2011 +0000
@@ -678,24 +678,31 @@
if (header[9] == '3' && header[10] == '0') {
/* 30x: URL redirection */
if ((location_str = Cache_parse_field(header, "Location"))) {
- DilloUrl *location_url;
-
- entry->Flags |= CA_Redirect;
- if (header[11] == '1')
- entry->Flags |= CA_ForceRedirect; /* 301 Moved Permanently */
- else if (header[11] == '2')
- entry->Flags |= CA_TempRedirect; /* 302 Temporary Redirect */
-
- location_url = a_Url_new(location_str, URL_STR_(entry->Url));
- if (URL_FLAGS(location_url) & (URL_Post + URL_Get) &&
- dStrcasecmp(URL_SCHEME(location_url), "dpi") == 0 &&
- dStrcasecmp(URL_SCHEME(entry->Url), "dpi") != 0) {
- /* Forbid dpi GET and POST from non dpi-generated urls */
- MSG("Redirection Denied! '%s' -> '%s'\n",
- URL_STR(entry->Url), URL_STR(location_url));
+ DilloUrl *location_url = a_Url_new(location_str,
+ URL_STR_(entry->Url));
+ if (prefs.filter_auto_requests == PREFS_FILTER_SAME_DOMAIN &&
+ !a_Url_same_organization(entry->Url, location_url)) {
+ /* don't redirect; just show body like usual (if any) */
+ MSG("Redirection not followed from %s to %s\n",
+ URL_HOST(entry->Url), URL_HOST(location_url));
a_Url_free(location_url);
} else {
- entry->Location = location_url;
+ entry->Flags |= CA_Redirect;
+ if (header[11] == '1')
+ entry->Flags |= CA_ForceRedirect; /* 301 Moved Permanently */
+ else if (header[11] == '2')
+ entry->Flags |= CA_TempRedirect; /* 302 Temporary Redirect*/
+
+ if (URL_FLAGS(location_url) & (URL_Post + URL_Get) &&
+ dStrcasecmp(URL_SCHEME(location_url), "dpi") == 0 &&
+ dStrcasecmp(URL_SCHEME(entry->Url), "dpi") != 0) {
+ /* Forbid dpi GET and POST from non dpi-generated urls */
+ MSG("Redirection Denied! '%s' -> '%s'\n",
+ URL_STR(entry->Url), URL_STR(location_url));
+ a_Url_free(location_url);
+ } else {
+ entry->Location = location_url;
+ }
}
dFree(location_str);
}