summaryrefslogtreecommitdiff
path: root/src/ui/documentwidget.c
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:02 +0300
commitf3d01757dfcbe9f9e63c6041a5b2152328c5fb2a (patch)
treeb65c50c3917cf72a988aab0a47f94dd4ea59e9a3 /src/ui/documentwidget.c
parentcbd1f6a89615e56b48438a5d3d4e2b2144d9692f (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/documentwidget.c')
-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));