commit 51762770ad906c93ca83830aee8d17f8acba8c29 from: Omar Polo date: Sat Dec 24 17:01:15 2022 UTC iri: lowercase scheme and host (part of URI normalization) commit - 36f94f06b08270ab5d4465aa61ae025c98e24c2c commit + 51762770ad906c93ca83830aee8d17f8acba8c29 blob - ac838023e0eb83c222129878c8b2b0eb79b3da8b blob + 31e85d1dd2901bc5a50da2e55c2c0a8892e79c27 --- iri.c +++ iri.c @@ -418,6 +418,13 @@ parse(const char *s, struct iri *iri) return (0); } +static inline void +lowerify(char *s) +{ + for (; *s; ++s) + *s = tolower((unsigned char)*s); +} + static void cpfields(struct iri *dest, const struct iri *src, int flags) { @@ -426,6 +433,7 @@ cpfields(struct iri *dest, const struct iri *src, int if (src->iri_flags & IH_SCHEME) memcpy(dest->iri_scheme, src->iri_scheme, sizeof(dest->iri_scheme)); + lowerify(dest->iri_scheme); } if (flags & IH_UINFO) { dest->iri_flags |= IH_UINFO; @@ -438,6 +446,7 @@ cpfields(struct iri *dest, const struct iri *src, int if (src->iri_flags & IH_HOST) memcpy(dest->iri_host, src->iri_host, sizeof(dest->iri_host)); + lowerify(dest->iri_host); } if (flags & IH_PORT) { dest->iri_flags |= IH_PORT;