diff options
-rw-r--r-- | src/app.c | 4 | ||||
-rw-r--r-- | src/gmdocument.c | 10 | ||||
-rw-r--r-- | src/gmrequest.c | 10 | ||||
-rw-r--r-- | src/gmutil.c | 34 | ||||
-rw-r--r-- | src/gmutil.h | 4 | ||||
-rw-r--r-- | src/ui/documentwidget.c | 9 | ||||
-rw-r--r-- | src/ui/sidebarwidget.c | 4 |
7 files changed, 37 insertions, 38 deletions
@@ -612,8 +612,8 @@ iBool handleCommand_App(const char *cmd) { | |||
612 | const iString *url = collect_String(newCStr_String(suffixPtr_Command(cmd, "url"))); | 612 | const iString *url = collect_String(newCStr_String(suffixPtr_Command(cmd, "url"))); |
613 | iUrl parts; | 613 | iUrl parts; |
614 | init_Url(&parts, url); | 614 | init_Url(&parts, url); |
615 | if (equalCase_Rangecc(parts.protocol, "http") || | 615 | if (equalCase_Rangecc(parts.scheme, "http") || |
616 | equalCase_Rangecc(parts.protocol, "https")) { | 616 | equalCase_Rangecc(parts.scheme, "https")) { |
617 | openInDefaultBrowser_App(url); | 617 | openInDefaultBrowser_App(url); |
618 | return iTrue; | 618 | return iTrue; |
619 | } | 619 | } |
diff --git a/src/gmdocument.c b/src/gmdocument.c index 4173a10c..368aed37 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c | |||
@@ -208,19 +208,19 @@ static iRangecc addLink_GmDocument_(iGmDocument *d, iRangecc line, iGmLinkId *li | |||
208 | if (!equalCase_Rangecc(parts.host, cstr_String(&d->localHost))) { | 208 | if (!equalCase_Rangecc(parts.host, cstr_String(&d->localHost))) { |
209 | link->flags |= remote_GmLinkFlag; | 209 | link->flags |= remote_GmLinkFlag; |
210 | } | 210 | } |
211 | if (startsWithCase_Rangecc(parts.protocol, "gemini")) { | 211 | if (startsWithCase_Rangecc(parts.scheme, "gemini")) { |
212 | link->flags |= gemini_GmLinkFlag; | 212 | link->flags |= gemini_GmLinkFlag; |
213 | } | 213 | } |
214 | else if (startsWithCase_Rangecc(parts.protocol, "http")) { | 214 | else if (startsWithCase_Rangecc(parts.scheme, "http")) { |
215 | link->flags |= http_GmLinkFlag; | 215 | link->flags |= http_GmLinkFlag; |
216 | } | 216 | } |
217 | else if (equalCase_Rangecc(parts.protocol, "gopher")) { | 217 | else if (equalCase_Rangecc(parts.scheme, "gopher")) { |
218 | link->flags |= gopher_GmLinkFlag; | 218 | link->flags |= gopher_GmLinkFlag; |
219 | } | 219 | } |
220 | else if (equalCase_Rangecc(parts.protocol, "file")) { | 220 | else if (equalCase_Rangecc(parts.scheme, "file")) { |
221 | link->flags |= file_GmLinkFlag; | 221 | link->flags |= file_GmLinkFlag; |
222 | } | 222 | } |
223 | else if (equalCase_Rangecc(parts.protocol, "data")) { | 223 | else if (equalCase_Rangecc(parts.scheme, "data")) { |
224 | link->flags |= data_GmLinkFlag; | 224 | link->flags |= data_GmLinkFlag; |
225 | } | 225 | } |
226 | /* Check the file name extension, if present. */ | 226 | /* Check the file name extension, if present. */ |
diff --git a/src/gmrequest.c b/src/gmrequest.c index ebb66a84..c2c94888 100644 --- a/src/gmrequest.c +++ b/src/gmrequest.c | |||
@@ -401,9 +401,9 @@ void submit_GmRequest(iGmRequest *d) { | |||
401 | clear_GmResponse(&d->resp); | 401 | clear_GmResponse(&d->resp); |
402 | iUrl url; | 402 | iUrl url; |
403 | init_Url(&url, &d->url); | 403 | init_Url(&url, &d->url); |
404 | /* Check for special protocols. */ | 404 | /* Check for special schemes. */ |
405 | /* TODO: If this were a library, these could be handled via callbacks. */ | 405 | /* TODO: If this were a library, these could be handled via callbacks. */ |
406 | if (equalCase_Rangecc(url.protocol, "about")) { | 406 | if (equalCase_Rangecc(url.scheme, "about")) { |
407 | const iBlock *src = aboutPageSource_(url.path); | 407 | const iBlock *src = aboutPageSource_(url.path); |
408 | if (src) { | 408 | if (src) { |
409 | d->resp.statusCode = success_GmStatusCode; | 409 | d->resp.statusCode = success_GmStatusCode; |
@@ -419,7 +419,7 @@ void submit_GmRequest(iGmRequest *d) { | |||
419 | iNotifyAudience(d, finished, GmRequestFinished); | 419 | iNotifyAudience(d, finished, GmRequestFinished); |
420 | return; | 420 | return; |
421 | } | 421 | } |
422 | else if (equalCase_Rangecc(url.protocol, "file")) { | 422 | else if (equalCase_Rangecc(url.scheme, "file")) { |
423 | iString *path = collect_String(urlDecode_String(collect_String(newRange_String(url.path)))); | 423 | iString *path = collect_String(urlDecode_String(collect_String(newRange_String(url.path)))); |
424 | iFile * f = new_File(path); | 424 | iFile * f = new_File(path); |
425 | if (open_File(f, readOnly_FileMode)) { | 425 | if (open_File(f, readOnly_FileMode)) { |
@@ -457,9 +457,9 @@ void submit_GmRequest(iGmRequest *d) { | |||
457 | iNotifyAudience(d, finished, GmRequestFinished); | 457 | iNotifyAudience(d, finished, GmRequestFinished); |
458 | return; | 458 | return; |
459 | } | 459 | } |
460 | else if (equalCase_Rangecc(url.protocol, "data")) { | 460 | else if (equalCase_Rangecc(url.scheme, "data")) { |
461 | d->resp.statusCode = success_GmStatusCode; | 461 | d->resp.statusCode = success_GmStatusCode; |
462 | iString *src = collectNewCStr_String(url.protocol.start + 5); | 462 | iString *src = collectNewCStr_String(url.scheme.start + 5); |
463 | iRangecc header = { constBegin_String(src), constBegin_String(src) }; | 463 | iRangecc header = { constBegin_String(src), constBegin_String(src) }; |
464 | while (header.end < constEnd_String(src) && *header.end != ',') { | 464 | while (header.end < constEnd_String(src) && *header.end != ',') { |
465 | header.end++; | 465 | header.end++; |
diff --git a/src/gmutil.c b/src/gmutil.c index 3af42cd1..ed3e7218 100644 --- a/src/gmutil.c +++ b/src/gmutil.c | |||
@@ -36,8 +36,8 @@ void init_Url(iUrl *d, const iString *text) { | |||
36 | iRegExpMatch m; | 36 | iRegExpMatch m; |
37 | init_RegExpMatch(&m); | 37 | init_RegExpMatch(&m); |
38 | if (matchString_RegExp(absoluteUrlPattern_, text, &m)) { | 38 | if (matchString_RegExp(absoluteUrlPattern_, text, &m)) { |
39 | d->protocol = capturedRange_RegExpMatch(&m, 1); | 39 | d->scheme = capturedRange_RegExpMatch(&m, 1); |
40 | d->host = capturedRange_RegExpMatch(&m, 2); | 40 | d->host = capturedRange_RegExpMatch(&m, 2); |
41 | if (!isEmpty_Range(&d->host)) { | 41 | if (!isEmpty_Range(&d->host)) { |
42 | d->host.start += 2; /* skip the double slash */ | 42 | d->host.start += 2; /* skip the double slash */ |
43 | } | 43 | } |
@@ -55,13 +55,13 @@ void init_Url(iUrl *d, const iString *text) { | |||
55 | relativeUrlPattern_ = new_RegExp("([a-z]+:)?([^?]*)(\\?.*)?", 0); | 55 | relativeUrlPattern_ = new_RegExp("([a-z]+:)?([^?]*)(\\?.*)?", 0); |
56 | } | 56 | } |
57 | if (matchString_RegExp(relativeUrlPattern_, text, &m)) { | 57 | if (matchString_RegExp(relativeUrlPattern_, text, &m)) { |
58 | d->protocol = capturedRange_RegExpMatch(&m, 1); | 58 | d->scheme = capturedRange_RegExpMatch(&m, 1); |
59 | d->path = capturedRange_RegExpMatch(&m, 2); | 59 | d->path = capturedRange_RegExpMatch(&m, 2); |
60 | d->query = capturedRange_RegExpMatch(&m, 3); | 60 | d->query = capturedRange_RegExpMatch(&m, 3); |
61 | } | 61 | } |
62 | } | 62 | } |
63 | if (!isEmpty_Range(&d->protocol)) { | 63 | if (!isEmpty_Range(&d->scheme)) { |
64 | d->protocol.end--; /* omit the colon */ | 64 | d->scheme.end--; /* omit the colon */ |
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
@@ -115,10 +115,10 @@ void cleanUrlPath_String(iString *d) { | |||
115 | deinit_String(&clean); | 115 | deinit_String(&clean); |
116 | } | 116 | } |
117 | 117 | ||
118 | iRangecc urlProtocol_String(const iString *d) { | 118 | iRangecc urlScheme_String(const iString *d) { |
119 | iUrl url; | 119 | iUrl url; |
120 | init_Url(&url, d); | 120 | init_Url(&url, d); |
121 | return url.protocol; | 121 | return url.scheme; |
122 | } | 122 | } |
123 | 123 | ||
124 | iRangecc urlHost_String(const iString *d) { | 124 | iRangecc urlHost_String(const iString *d) { |
@@ -132,20 +132,20 @@ const iString *absoluteUrl_String(const iString *d, const iString *urlMaybeRelat | |||
132 | iUrl rel; | 132 | iUrl rel; |
133 | init_Url(&orig, d); | 133 | init_Url(&orig, d); |
134 | init_Url(&rel, urlMaybeRelative); | 134 | init_Url(&rel, urlMaybeRelative); |
135 | if (equalCase_Rangecc(rel.protocol, "data") || equalCase_Rangecc(rel.protocol, "about")) { | 135 | if (equalCase_Rangecc(rel.scheme, "data") || equalCase_Rangecc(rel.scheme, "about")) { |
136 | /* Special case, the contents should be left unparsed. */ | 136 | /* Special case, the contents should be left unparsed. */ |
137 | return urlMaybeRelative; | 137 | return urlMaybeRelative; |
138 | } | 138 | } |
139 | const iBool isRelative = !isDef_(rel.host); | 139 | const iBool isRelative = !isDef_(rel.host); |
140 | iRangecc protocol = range_CStr("gemini"); | 140 | iRangecc scheme = range_CStr("gemini"); |
141 | if (isDef_(rel.protocol)) { | 141 | if (isDef_(rel.scheme)) { |
142 | protocol = rel.protocol; | 142 | scheme = rel.scheme; |
143 | } | 143 | } |
144 | else if (isRelative && isDef_(orig.protocol)) { | 144 | else if (isRelative && isDef_(orig.scheme)) { |
145 | protocol = orig.protocol; | 145 | scheme = orig.scheme; |
146 | } | 146 | } |
147 | iString *absolute = collectNew_String(); | 147 | iString *absolute = collectNew_String(); |
148 | appendRange_String(absolute, protocol); | 148 | appendRange_String(absolute, scheme); |
149 | appendCStr_String(absolute, "://"); { | 149 | appendCStr_String(absolute, "://"); { |
150 | const iUrl *selHost = isDef_(rel.host) ? &rel : &orig; | 150 | const iUrl *selHost = isDef_(rel.host) ? &rel : &orig; |
151 | appendRange_String(absolute, selHost->host); | 151 | appendRange_String(absolute, selHost->host); |
@@ -154,7 +154,7 @@ const iString *absoluteUrl_String(const iString *d, const iString *urlMaybeRelat | |||
154 | appendRange_String(absolute, selHost->port); | 154 | appendRange_String(absolute, selHost->port); |
155 | } | 155 | } |
156 | } | 156 | } |
157 | if (isDef_(rel.protocol) || isDef_(rel.host) || startsWith_Rangecc(rel.path, "/")) { | 157 | if (isDef_(rel.scheme) || isDef_(rel.host) || startsWith_Rangecc(rel.path, "/")) { |
158 | appendRange_String(absolute, rel.path); /* absolute path */ | 158 | appendRange_String(absolute, rel.path); /* absolute path */ |
159 | } | 159 | } |
160 | else { | 160 | else { |
diff --git a/src/gmutil.h b/src/gmutil.h index 999fb7cf..72ca5fed 100644 --- a/src/gmutil.h +++ b/src/gmutil.h | |||
@@ -83,7 +83,7 @@ iBool isDefined_GmError (enum iGmStatusCode code); | |||
83 | const iGmError * get_GmError (enum iGmStatusCode code); | 83 | const iGmError * get_GmError (enum iGmStatusCode code); |
84 | 84 | ||
85 | struct Impl_Url { | 85 | struct Impl_Url { |
86 | iRangecc protocol; | 86 | iRangecc scheme; |
87 | iRangecc host; | 87 | iRangecc host; |
88 | iRangecc port; | 88 | iRangecc port; |
89 | iRangecc path; | 89 | iRangecc path; |
@@ -92,7 +92,7 @@ struct Impl_Url { | |||
92 | 92 | ||
93 | void init_Url (iUrl *, const iString *text); | 93 | void init_Url (iUrl *, const iString *text); |
94 | 94 | ||
95 | iRangecc urlProtocol_String (const iString *); | 95 | iRangecc urlScheme_String (const iString *); |
96 | iRangecc urlHost_String (const iString *); | 96 | iRangecc urlHost_String (const iString *); |
97 | const iString * absoluteUrl_String (const iString *, const iString *urlMaybeRelative); | 97 | const iString * absoluteUrl_String (const iString *, const iString *urlMaybeRelative); |
98 | iString * makeFileUrl_String (const iString *localFilePath); | 98 | iString * makeFileUrl_String (const iString *localFilePath); |
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 8885bb9b..ed6c2518 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -788,7 +788,7 @@ static void checkResponse_DocumentWidget_(iDocumentWidget *d) { | |||
788 | showErrorPage_DocumentWidget_(d, invalidRedirect_GmStatusCode); | 788 | showErrorPage_DocumentWidget_(d, invalidRedirect_GmStatusCode); |
789 | } | 789 | } |
790 | else { | 790 | else { |
791 | /* TODO: only accept redirects that use gemini protocol */ | 791 | /* TODO: only accept redirects that use gemini scheme */ |
792 | postCommandf_App( | 792 | postCommandf_App( |
793 | "open redirect:1 url:%s", | 793 | "open redirect:1 url:%s", |
794 | cstr_String(absoluteUrl_String(d->mod.url, meta_GmRequest(d->request)))); | 794 | cstr_String(absoluteUrl_String(d->mod.url, meta_GmRequest(d->request)))); |
@@ -1079,8 +1079,7 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
1079 | d->scrollY = d->initNormScrollY * size_GmDocument(d->doc).y; | 1079 | d->scrollY = d->initNormScrollY * size_GmDocument(d->doc).y; |
1080 | d->state = ready_RequestState; | 1080 | d->state = ready_RequestState; |
1081 | /* The response may be cached. */ { | 1081 | /* The response may be cached. */ { |
1082 | const iRangecc proto = urlProtocol_String(d->mod.url); | 1082 | if (!equal_Rangecc(urlScheme_String(d->mod.url), "about")) { |
1083 | if (!equal_Rangecc(proto, "about")) { | ||
1084 | setCachedResponse_History(d->mod.history, response_GmRequest(d->request)); | 1083 | setCachedResponse_History(d->mod.history, response_GmRequest(d->request)); |
1085 | } | 1084 | } |
1086 | } | 1085 | } |
@@ -1604,9 +1603,9 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) { | |||
1604 | &str, | 1603 | &str, |
1605 | " \u2014%s%s%s\r%c%s", | 1604 | " \u2014%s%s%s\r%c%s", |
1606 | showHost ? " " : "", | 1605 | showHost ? " " : "", |
1607 | showHost ? (!equalCase_Rangecc(parts.protocol, "gemini") | 1606 | showHost ? (!equalCase_Rangecc(parts.scheme, "gemini") |
1608 | ? format_CStr("%s://%s", | 1607 | ? format_CStr("%s://%s", |
1609 | cstr_Rangecc(parts.protocol), | 1608 | cstr_Rangecc(parts.scheme), |
1610 | cstr_Rangecc(parts.host)) | 1609 | cstr_Rangecc(parts.host)) |
1611 | : cstr_Rangecc(parts.host)) | 1610 | : cstr_Rangecc(parts.host)) |
1612 | : "", | 1611 | : "", |
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c index e3d7d4a6..8b0792c8 100644 --- a/src/ui/sidebarwidget.c +++ b/src/ui/sidebarwidget.c | |||
@@ -771,14 +771,14 @@ static void draw_SidebarWidget_(const iSidebarWidget *d) { | |||
771 | else { | 771 | else { |
772 | iUrl parts; | 772 | iUrl parts; |
773 | init_Url(&parts, &item->url); | 773 | init_Url(&parts, &item->url); |
774 | const iBool isGemini = equalCase_Rangecc(parts.protocol, "gemini"); | 774 | const iBool isGemini = equalCase_Rangecc(parts.scheme, "gemini"); |
775 | draw_Text( | 775 | draw_Text( |
776 | font, | 776 | font, |
777 | add_I2(topLeft_Rect(itemRect), | 777 | add_I2(topLeft_Rect(itemRect), |
778 | init_I2(3 * gap_UI, (d->itemHeight - lineHeight_Text(font)) / 2)), | 778 | init_I2(3 * gap_UI, (d->itemHeight - lineHeight_Text(font)) / 2)), |
779 | fg, | 779 | fg, |
780 | "%s%s%s%s%s%s", | 780 | "%s%s%s%s%s%s", |
781 | isGemini ? "" : cstr_Rangecc(parts.protocol), | 781 | isGemini ? "" : cstr_Rangecc(parts.scheme), |
782 | isGemini ? "" : "://", | 782 | isGemini ? "" : "://", |
783 | escape_Color(isHover ? (isPressing ? uiTextPressed_ColorId | 783 | escape_Color(isHover ? (isPressing ? uiTextPressed_ColorId |
784 | : uiTextFramelessHover_ColorId) | 784 | : uiTextFramelessHover_ColorId) |