diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-11-06 21:59:39 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-11-06 21:59:39 +0200 |
commit | a3af3912421d5848bce9eac7031da406bac2ba5b (patch) | |
tree | ff62ad49b9a95da4e863ccbc60ff2fdf02692f13 | |
parent | 4f92d0b2930a023fd4a000aabf797e5a37061b81 (diff) |
Automatic redirects to the same scheme
IssueID #16
-rw-r--r-- | res/about/version.gmi | 1 | ||||
-rw-r--r-- | src/gmutil.c | 8 | ||||
-rw-r--r-- | src/gmutil.h | 2 | ||||
-rw-r--r-- | src/ui/documentwidget.c | 9 |
4 files changed, 12 insertions, 8 deletions
diff --git a/res/about/version.gmi b/res/about/version.gmi index 0192eaaa..12c00b3b 100644 --- a/res/about/version.gmi +++ b/res/about/version.gmi | |||
@@ -13,6 +13,7 @@ | |||
13 | * Added a context menu item for opening HTTP links in the default browser even when a proxy is configured. | 13 | * Added a context menu item for opening HTTP links in the default browser even when a proxy is configured. |
14 | * ${CTRL+}Click opens tab in background, ${SHIFT+}${CTRL+}Click opens as foreground tab. The same modifier keys work with keyboard navigation. | 14 | * ${CTRL+}Click opens tab in background, ${SHIFT+}${CTRL+}Click opens as foreground tab. The same modifier keys work with keyboard navigation. |
15 | * Improved word wrapping of emoticons (:D). | 15 | * Improved word wrapping of emoticons (:D). |
16 | * Automatic redirects allowed when the destination URL uses the same scheme as the originating URL. For example, when using a proxy, HTTP(S) is allowed to automatically redirect to other HTTP(S) URLs. | ||
16 | * Windows: Fixed handling of drag-and-dropped and command line file paths. | 17 | * Windows: Fixed handling of drag-and-dropped and command line file paths. |
17 | 18 | ||
18 | ## 0.7.2 | 19 | ## 0.7.2 |
diff --git a/src/gmutil.c b/src/gmutil.c index 52fe6b28..6166efd6 100644 --- a/src/gmutil.c +++ b/src/gmutil.c | |||
@@ -247,11 +247,11 @@ static const struct { | |||
247 | "Invalid Redirect", | 247 | "Invalid Redirect", |
248 | "The server responded with a redirect but did not provide a valid destination URL. " | 248 | "The server responded with a redirect but did not provide a valid destination URL. " |
249 | "Perhaps the server is malfunctioning." } }, | 249 | "Perhaps the server is malfunctioning." } }, |
250 | { nonGeminiRedirect_GmStatusCode, | 250 | { schemeChangeRedirect_GmStatusCode, |
251 | { 0x27a0, /* dashed arrow */ | 251 | { 0x27a0, /* dashed arrow */ |
252 | "Redirect to Non-Gemini URL", | 252 | "Scheme-Changing Redirect", |
253 | "The server attempted to redirect us to a non-Gemini URL. Here is the link so you " | 253 | "The server attempted to redirect us to a URL whose scheme is different than the " |
254 | "can open it manually if appropriate."} }, | 254 | "originating URL's scheme. Here is the link so you can open it manually if appropriate."} }, |
255 | { tooManyRedirects_GmStatusCode, | 255 | { tooManyRedirects_GmStatusCode, |
256 | { 0x27a0, /* dashed arrow */ | 256 | { 0x27a0, /* dashed arrow */ |
257 | "Too Many Redirects", | 257 | "Too Many Redirects", |
diff --git a/src/gmutil.h b/src/gmutil.h index 97c2d675..6778465a 100644 --- a/src/gmutil.h +++ b/src/gmutil.h | |||
@@ -33,7 +33,7 @@ enum iGmStatusCode { | |||
33 | /* clientside status codes */ | 33 | /* clientside status codes */ |
34 | clientSide_GmStatusCode = -100, | 34 | clientSide_GmStatusCode = -100, |
35 | invalidRedirect_GmStatusCode, | 35 | invalidRedirect_GmStatusCode, |
36 | nonGeminiRedirect_GmStatusCode, | 36 | schemeChangeRedirect_GmStatusCode, |
37 | tooManyRedirects_GmStatusCode, | 37 | tooManyRedirects_GmStatusCode, |
38 | invalidHeader_GmStatusCode, | 38 | invalidHeader_GmStatusCode, |
39 | unsupportedMimeType_GmStatusCode, | 39 | unsupportedMimeType_GmStatusCode, |
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index f1506fc3..1b6e485a 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -694,7 +694,7 @@ static void showErrorPage_DocumentWidget_(iDocumentWidget *d, enum iGmStatusCode | |||
694 | iBool useBanner = iTrue; | 694 | iBool useBanner = iTrue; |
695 | if (meta) { | 695 | if (meta) { |
696 | switch (code) { | 696 | switch (code) { |
697 | case nonGeminiRedirect_GmStatusCode: | 697 | case schemeChangeRedirect_GmStatusCode: |
698 | case tooManyRedirects_GmStatusCode: | 698 | case tooManyRedirects_GmStatusCode: |
699 | appendFormat_String(src, "\n=> %s\n", cstr_String(meta)); | 699 | appendFormat_String(src, "\n=> %s\n", cstr_String(meta)); |
700 | break; | 700 | break; |
@@ -1031,12 +1031,15 @@ static void checkResponse_DocumentWidget_(iDocumentWidget *d) { | |||
1031 | if (d->redirectCount >= 5) { | 1031 | if (d->redirectCount >= 5) { |
1032 | showErrorPage_DocumentWidget_(d, tooManyRedirects_GmStatusCode, dstUrl); | 1032 | showErrorPage_DocumentWidget_(d, tooManyRedirects_GmStatusCode, dstUrl); |
1033 | } | 1033 | } |
1034 | else if (equalCase_Rangecc(urlScheme_String(dstUrl), "gemini")) { | 1034 | else if (equalCase_Rangecc(urlScheme_String(dstUrl), |
1035 | cstr_Rangecc(urlScheme_String(d->mod.url)))) { | ||
1036 | /* Redirects with the same scheme are automatic. */ | ||
1035 | postCommandf_App( | 1037 | postCommandf_App( |
1036 | "open redirect:%d url:%s", d->redirectCount + 1, cstr_String(dstUrl)); | 1038 | "open redirect:%d url:%s", d->redirectCount + 1, cstr_String(dstUrl)); |
1037 | } | 1039 | } |
1038 | else { | 1040 | else { |
1039 | showErrorPage_DocumentWidget_(d, nonGeminiRedirect_GmStatusCode, dstUrl); | 1041 | /* Scheme changes must be manually approved. */ |
1042 | showErrorPage_DocumentWidget_(d, schemeChangeRedirect_GmStatusCode, dstUrl); | ||
1040 | } | 1043 | } |
1041 | iReleasePtr(&d->request); | 1044 | iReleasePtr(&d->request); |
1042 | } | 1045 | } |