aboutsummaryrefslogtreecommitdiff
path: root/iri.c
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2021-01-15 09:27:42 +0000
committerOmar Polo <op@omarpolo.com>2021-01-15 09:27:42 +0000
commite4d82becb71b1b8f9c843a5f0f8657bc6b93c67b (patch)
tree6dd08f9b3b6bc14a573d31f00026dc7a2c3e49d3 /iri.c
parent15902770073dd67df3a9af0f6da7d63bfb031d72 (diff)
normalize host name when parsing the IRI
RFC3986 3.2.2 "Host" says that > Although host is case-insensitive, producers and normalizers should > use lowercase for registered names and hexadecimal addresses for the > sake of uniformity, while only using uppercase letters for > percent-encodings. so we cope with that.
Diffstat (limited to 'iri.c')
-rw-r--r--iri.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/iri.c b/iri.c
index 1b997dd..d64afe8 100644
--- a/iri.c
+++ b/iri.c
@@ -146,8 +146,12 @@ parse_authority(struct parser *p)
while (unreserved(*p->iri)
|| sub_delimiters(*p->iri)
- || parse_pct_encoded(p))
+ || parse_pct_encoded(p)) {
+ /* normalize the host name. */
+ if (*p->iri < 0x7F)
+ *p->iri = tolower(*p->iri);
p->iri++;
+ }
if (p->err != NULL)
return 0;