Repository navigation
fix: preserve URI component case in equality - #207
Conversation
Tony133
left a comment
There was a problem hiding this comment.
LGTM! Quick question: normalizeComparableURI now also catches malformed object inputs (e.g. port: 99999), which used to slip through unchecked. On main, two identical malformed objects return equal() === true; per the README (https://github.com/fastify/fast-uri/blob/main/README.md?plain=1#L16), this branch correctly returns false. Intentional? Might be worth a regression test either way. For example:
test('URI Equals rejects malformed object input even when identical', (t) => {
const suite = [
{
pair: [
{ scheme: 'http', host: 'example.com', port: 99999, path: '/x' },
{ scheme: 'http', host: 'example.com', port: 99999, path: '/x' }
],
result: false
}
]
runTest(t, suite)
t.end()
})|
@Tony133 Yes, intentional. Object inputs are serialized and then passed through the same malformed-input validation as strings, so I added the suggested regression coverage in 2a6412d. Thanks for catching the missing test! |
* fix: preserve URI component case in equality * test: cover malformed object equality
* fix: preserve URI component case in equality * test: cover malformed object equality Case-insensitive folding of scheme and host now happens during parse (scheme validation backport) instead of a blanket toLowerCase.
Correct
equal()so normalization controls case folding instead of lowercasing the complete URI. This preserves case-sensitive path, query, fragment, userinfo, WebSocket resource, and URN NSS data while retaining scheme, host, and scheme-specific normalization.This is a correctness and defense-in-depth fix for GHSA-wwpg-6wxh-phxg. No concrete security boundary bypass has been established, so it should not be characterized as a vulnerability.