summaryrefslogtreecommitdiff
path: root/src/gmrequest.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-12-27 10:00:17 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-12-27 10:00:17 +0200
commit5e31f66313e2dc15fb9e75395504feb0992c3feb (patch)
treec43a734bd9ed2d1da671b8c885ef6af028c1b25f /src/gmrequest.c
parentcf0b3924268ffe03d8c30dfa553deba79802e41f (diff)
Reserved characters in URLs
Making URL encoding a little less convoluted. Now when sending out a request, the URL is fully encoded except for reserved characters. In the internal representation, non-ASCII characters are in decoded form (i.e., IRI). This means that if the user enters a URL in the input field manually, its non-ASCII characters will be percent encoded as well. However, in this case the user is expected to manually escape all reserved characters because the input field can't tell the difference between what is intended to be a reserved separator and what isn't. For example, a server might expect &-separated fields, and if the user enters such fields manually in the URL field, they shouldn't be converted to %26. When forming a query URL in the input dialog, user-entered text is fully percent-encoded because in that case the input is just a generic text string. IssueID #410
Diffstat (limited to 'src/gmrequest.c')
-rw-r--r--src/gmrequest.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/gmrequest.c b/src/gmrequest.c
index a9c5919d..c23e8499 100644
--- a/src/gmrequest.c
+++ b/src/gmrequest.c
@@ -585,8 +585,10 @@ void setUrl_GmRequest(iGmRequest *d, const iString *url) {
585 /* TODO: Gemini spec allows UTF-8 encoded URLs, but still need to percent-encode non-ASCII 585 /* TODO: Gemini spec allows UTF-8 encoded URLs, but still need to percent-encode non-ASCII
586 characters? Could be a server-side issue, e.g., if they're using a URL parser meant for 586 characters? Could be a server-side issue, e.g., if they're using a URL parser meant for
587 the web. */ 587 the web. */
588 urlEncodePath_String(&d->url); 588 /* Encode everything except already-percent encoded characters. */
589 urlEncodeSpaces_String(&d->url); 589 iString *enc = urlEncodeExclude_String(&d->url, "%" URL_RESERVED_CHARS);
590 set_String(&d->url, enc);
591 delete_String(enc);
590 d->identity = identityForUrl_GmCerts(d->certs, &d->url); 592 d->identity = identityForUrl_GmCerts(d->certs, &d->url);
591} 593}
592 594