summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-11-07 12:41:01 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-11-07 12:41:01 +0200
commit64b9848f878ccd75aae75bf4d8d3f8a364f28ddc (patch)
treebc56660823e5dd2658fe4ef7535086011dd717c4
parentf309d604a720a9442c2249d3a738f746d1503b47 (diff)
Treat Gopher as an unsupported protocol
-rw-r--r--src/app.c21
-rw-r--r--src/gmdocument.c6
-rw-r--r--src/gmrequest.c6
-rw-r--r--src/gmutil.c5
-rw-r--r--src/gmutil.h1
5 files changed, 25 insertions, 14 deletions
diff --git a/src/app.c b/src/app.c
index a76e135b..9a8e78ae 100644
--- a/src/app.c
+++ b/src/app.c
@@ -612,13 +612,14 @@ enum iColorTheme colorTheme_App(void) {
612 612
613const iString *schemeProxy_App(iRangecc scheme) { 613const iString *schemeProxy_App(iRangecc scheme) {
614 iApp *d = &app_; 614 iApp *d = &app_;
615 const iString *proxy = NULL;
615 if (equalCase_Rangecc(scheme, "gopher")) { 616 if (equalCase_Rangecc(scheme, "gopher")) {
616 return &d->prefs.gopherProxy; 617 proxy = &d->prefs.gopherProxy;
617 } 618 }
618 if (equalCase_Rangecc(scheme, "http") || equalCase_Rangecc(scheme, "https")) { 619 if (equalCase_Rangecc(scheme, "http") || equalCase_Rangecc(scheme, "https")) {
619 return &d->prefs.httpProxy; 620 proxy = &d->prefs.httpProxy;
620 } 621 }
621 return NULL; 622 return !isEmpty_String(proxy) ? proxy : NULL;
622} 623}
623 624
624int run_App(int argc, char **argv) { 625int run_App(int argc, char **argv) {
@@ -884,15 +885,7 @@ static iBool handleIdentityCreationCommands_(iWidget *dlg, const char *cmd) {
884} 885}
885 886
886iBool willUseProxy_App(const iRangecc scheme) { 887iBool willUseProxy_App(const iRangecc scheme) {
887 iApp *d = &app_; 888 return schemeProxy_App(scheme) != NULL;
888 if (!isEmpty_String(&d->prefs.httpProxy) && (equalCase_Rangecc(scheme, "http") ||
889 equalCase_Rangecc(scheme, "https"))) {
890 return iTrue;
891 }
892 if (!isEmpty_String(&d->prefs.gopherProxy) && equalCase_Rangecc(scheme, "gopher")) {
893 return iTrue;
894 }
895 return iFalse;
896} 889}
897 890
898iBool handleCommand_App(const char *cmd) { 891iBool handleCommand_App(const char *cmd) {
@@ -1203,6 +1196,10 @@ iBool handleCommand_App(const char *cmd) {
1203 save_Bookmarks(d->bookmarks, dataDir_App_); 1196 save_Bookmarks(d->bookmarks, dataDir_App_);
1204 return iFalse; 1197 return iFalse;
1205 } 1198 }
1199 else if (equal_Command(cmd, "visited.changed")) {
1200 save_Visited(d->visited, dataDir_App_);
1201 return iFalse;
1202 }
1206 else if (equal_Command(cmd, "ident.new")) { 1203 else if (equal_Command(cmd, "ident.new")) {
1207 iWidget *dlg = makeIdentityCreation_Widget(); 1204 iWidget *dlg = makeIdentityCreation_Widget();
1208 setCommandHandler_Widget(dlg, handleIdentityCreationCommands_); 1205 setCommandHandler_Widget(dlg, handleIdentityCreationCommands_);
diff --git a/src/gmdocument.c b/src/gmdocument.c
index 50733252..4e8b5ace 100644
--- a/src/gmdocument.c
+++ b/src/gmdocument.c
@@ -235,12 +235,14 @@ static void clearLinks_GmDocument_(iGmDocument *d) {
235 clear_PtrArray(&d->links); 235 clear_PtrArray(&d->links);
236} 236}
237 237
238#if 0
238static iBool isGopher_GmDocument_(const iGmDocument *d) { 239static iBool isGopher_GmDocument_(const iGmDocument *d) {
239 return equalCase_Rangecc(urlScheme_String(&d->url), "gopher"); 240 return equalCase_Rangecc(urlScheme_String(&d->url), "gopher");
240} 241}
242#endif
241 243
242static void doLayout_GmDocument_(iGmDocument *d) { 244static void doLayout_GmDocument_(iGmDocument *d) {
243 const iBool isGemini = !isGopher_GmDocument_(d); 245 const iBool isGemini = iTrue; // !isGopher_GmDocument_(d);
244 /* TODO: Collect these parameters into a GmTheme. */ 246 /* TODO: Collect these parameters into a GmTheme. */
245 const int fonts[max_GmLineType] = { 247 const int fonts[max_GmLineType] = {
246 isGemini ? paragraph_FontId : preformatted_FontId, 248 isGemini ? paragraph_FontId : preformatted_FontId,
@@ -1081,7 +1083,7 @@ static void normalize_GmDocument(iGmDocument *d) {
1081 iRangecc src = range_String(&d->source); 1083 iRangecc src = range_String(&d->source);
1082 iRangecc line = iNullRange; 1084 iRangecc line = iNullRange;
1083 iBool isPreformat = iFalse; 1085 iBool isPreformat = iFalse;
1084 if (d->format == plainText_GmDocumentFormat || isGopher_GmDocument_(d)) { 1086 if (d->format == plainText_GmDocumentFormat) { // || isGopher_GmDocument_(d)) {
1085 isPreformat = iTrue; /* Cannot be turned off. */ 1087 isPreformat = iTrue; /* Cannot be turned off. */
1086 } 1088 }
1087 const int preTabWidth = 4; /* TODO: user-configurable parameter */ 1089 const int preTabWidth = 4; /* TODO: user-configurable parameter */
diff --git a/src/gmrequest.c b/src/gmrequest.c
index f15d80f1..a83a7666 100644
--- a/src/gmrequest.c
+++ b/src/gmrequest.c
@@ -534,6 +534,12 @@ void submit_GmRequest(iGmRequest *d) {
534 port = 0; 534 port = 0;
535 } 535 }
536 } 536 }
537 else if (!equalCase_Rangecc(url.scheme, "gemini")) {
538 d->resp.statusCode = unsupportedProtocol_GmStatusCode;
539 d->state = finished_GmRequestState;
540 iNotifyAudience(d, finished, GmRequestFinished);
541 return;
542 }
537 d->state = receivingHeader_GmRequestState; 543 d->state = receivingHeader_GmRequestState;
538 d->req = new_TlsRequest(); 544 d->req = new_TlsRequest();
539 const iGmIdentity *identity = identityForUrl_GmCerts(d->certs, &d->url); 545 const iGmIdentity *identity = identityForUrl_GmCerts(d->certs, &d->url);
diff --git a/src/gmutil.c b/src/gmutil.c
index 6166efd6..369aaaf1 100644
--- a/src/gmutil.c
+++ b/src/gmutil.c
@@ -236,6 +236,11 @@ static const struct {
236 { 0x1f47d, /* alien */ 236 { 0x1f47d, /* alien */
237 "Unsupported Content Type", 237 "Unsupported Content Type",
238 "The received content cannot be viewed with this application." } }, 238 "The received content cannot be viewed with this application." } },
239 { unsupportedProtocol_GmStatusCode,
240 { 0x1f61e, /* disappointed */
241 "Unsupported Protocol",
242 "The requested protocol is not supported by this application." },
243 },
239 { invalidHeader_GmStatusCode, 244 { invalidHeader_GmStatusCode,
240 { 0x1f4a9, /* pile of poo */ 245 { 0x1f4a9, /* pile of poo */
241 "Invalid Header", 246 "Invalid Header",
diff --git a/src/gmutil.h b/src/gmutil.h
index 6778465a..e7022cfa 100644
--- a/src/gmutil.h
+++ b/src/gmutil.h
@@ -37,6 +37,7 @@ enum iGmStatusCode {
37 tooManyRedirects_GmStatusCode, 37 tooManyRedirects_GmStatusCode,
38 invalidHeader_GmStatusCode, 38 invalidHeader_GmStatusCode,
39 unsupportedMimeType_GmStatusCode, 39 unsupportedMimeType_GmStatusCode,
40 unsupportedProtocol_GmStatusCode,
40 failedToOpenFile_GmStatusCode, 41 failedToOpenFile_GmStatusCode,
41 unknownStatusCode_GmStatusCode, 42 unknownStatusCode_GmStatusCode,
42 invalidLocalResource_GmStatusCode, 43 invalidLocalResource_GmStatusCode,