From e0227219f707e6378aefd5991be2eddaa135daa4 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Thu, 28 May 2026 09:08:46 +0800 Subject: [PATCH] fix: stricter RFC 3986 character set --- yazi-shim/src/percent_encoding.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/yazi-shim/src/percent_encoding.rs b/yazi-shim/src/percent_encoding.rs index d2b28111..24e9ce54 100644 --- a/yazi-shim/src/percent_encoding.rs +++ b/yazi-shim/src/percent_encoding.rs @@ -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'}');