summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-08-02 11:44:02 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-08-02 11:44:11 +0300
commitc39fd136faa9388ea782a7615bca90224400b802 (patch)
treee022309980cadb629645c76def5514513d4bc078 /src/ui
parentedebcda032c18fcfda566b415aae6107f0dcd31a (diff)
DocumentWidget: Redirecting between gemini/titan schemes
Automatic redirects between `gemini` and `titan` are allowed, because a reasonable response to a Titan request is a redirect to a Gemini URL. Gemini may likewise redirect to a Titan URL to initiate an upload.
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/documentwidget.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 9c8be416..e1be27c2 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -1939,13 +1939,19 @@ static void checkResponse_DocumentWidget_(iDocumentWidget *d) {
1939 } 1939 }
1940 else { 1940 else {
1941 /* Only accept redirects that use gemini scheme. */ 1941 /* Only accept redirects that use gemini scheme. */
1942 const iString *dstUrl = absoluteUrl_String(d->mod.url, &resp->meta); 1942 const iString *dstUrl = absoluteUrl_String(d->mod.url, &resp->meta);
1943 const iRangecc srcScheme = urlScheme_String(d->mod.url);
1944 const iRangecc dstScheme = urlScheme_String(dstUrl);
1943 if (d->redirectCount >= 5) { 1945 if (d->redirectCount >= 5) {
1944 showErrorPage_DocumentWidget_(d, tooManyRedirects_GmStatusCode, dstUrl); 1946 showErrorPage_DocumentWidget_(d, tooManyRedirects_GmStatusCode, dstUrl);
1945 } 1947 }
1946 else if (equalCase_Rangecc(urlScheme_String(dstUrl), 1948 /* Redirects with the same scheme are automatic, and switching automatically
1947 cstr_Rangecc(urlScheme_String(d->mod.url)))) { 1949 between "gemini" and "titan" is allowed. */
1948 /* Redirects with the same scheme are automatic. */ 1950 else if (equalRangeCase_Rangecc(dstScheme, srcScheme) ||
1951 (equalCase_Rangecc(srcScheme, "titan") &&
1952 equalCase_Rangecc(dstScheme, "gemini")) ||
1953 (equalCase_Rangecc(srcScheme, "gemini") &&
1954 equalCase_Rangecc(dstScheme, "titan"))) {
1949 visitUrl_Visited(visited_App(), d->mod.url, transient_VisitedUrlFlag); 1955 visitUrl_Visited(visited_App(), d->mod.url, transient_VisitedUrlFlag);
1950 postCommandf_Root(as_Widget(d)->root, 1956 postCommandf_Root(as_Widget(d)->root,
1951 "open doc:%p redirect:%d url:%s", d, d->redirectCount + 1, cstr_String(dstUrl)); 1957 "open doc:%p redirect:%d url:%s", d, d->redirectCount + 1, cstr_String(dstUrl));