diff options
-rw-r--r-- | src/gmutil.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/gmutil.c b/src/gmutil.c index 5bb3732c..df77a3e0 100644 --- a/src/gmutil.c +++ b/src/gmutil.c | |||
@@ -252,14 +252,24 @@ void urlEncodePath_String(iString *d) { | |||
252 | delete_String(encoded); | 252 | delete_String(encoded); |
253 | } | 253 | } |
254 | 254 | ||
255 | static iBool isSupportedUrlScheme_Rangecc_(iRangecc scheme) { | ||
256 | static const char *schemes[] = { "gemini", "gopher", "finger", "http", "https", "file" }; | ||
257 | iForIndices(i, schemes) { | ||
258 | if (equalCase_Rangecc(scheme, schemes[i])) { | ||
259 | return iTrue; | ||
260 | } | ||
261 | } | ||
262 | return iFalse; | ||
263 | } | ||
264 | |||
255 | const iString *absoluteUrl_String(const iString *d, const iString *urlMaybeRelative) { | 265 | const iString *absoluteUrl_String(const iString *d, const iString *urlMaybeRelative) { |
256 | iUrl orig; | 266 | iUrl orig; |
257 | iUrl rel; | 267 | iUrl rel; |
258 | init_Url(&orig, d); | 268 | init_Url(&orig, d); |
259 | init_Url(&rel, urlMaybeRelative); | 269 | init_Url(&rel, urlMaybeRelative); |
260 | if (equalCase_Rangecc(rel.scheme, "data") || equalCase_Rangecc(rel.scheme, "about") || | 270 | if (!isEmpty_Range(&rel.scheme) && !isSupportedUrlScheme_Rangecc_(rel.scheme) && |
261 | equalCase_Rangecc(rel.scheme, "bitcoin") || equalCase_Rangecc(rel.scheme, "mailto")) { | 271 | isEmpty_Range(&rel.host)) { |
262 | /* Special case, the contents should be left unparsed. */ | 272 | /* Probably not an URL, so we can't make this absolute. */ |
263 | return urlMaybeRelative; | 273 | return urlMaybeRelative; |
264 | } | 274 | } |
265 | const iBool isRelative = !isDef_(rel.host); | 275 | const iBool isRelative = !isDef_(rel.host); |