fix: stricter RFC 3986 character set

This commit is contained in:
sxyazi 2026-05-28 09:08:46 +08:00
parent 7fe3bf5841
commit e0227219f7
No known key found for this signature in database

View file

@ -1,5 +1,20 @@
use percent_encoding::{AsciiSet, NON_ALPHANUMERIC};
use percent_encoding::{AsciiSet, CONTROLS};
// RFC 3986 path component: encode everything that is not a safe path character.
pub const RFC_3986: &AsciiSet =
&NON_ALPHANUMERIC.remove(b'-').remove(b'.').remove(b'_').remove(b'~');
// Safe chars: unreserved (A-Za-z0-9 -._~) + sub-delims (!$&'()*+,;=) + : @ /
pub const RFC_3986: &AsciiSet = &CONTROLS
.add(b' ')
.add(b'"')
.add(b'#')
.add(b'%')
.add(b'<')
.add(b'>')
.add(b'?')
.add(b'[')
.add(b'\\')
.add(b']')
.add(b'^')
.add(b'`')
.add(b'{')
.add(b'|')
.add(b'}');