From bc990465e2965103bc5f466f1a09336bdf7ce2ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=88=E9=9B=A8?= <228542279+qiyuhuating@users.noreply.github.com> Date: Sat, 28 Nov 2026 13:27:28 +0000 Subject: [PATCH] perf(policy): bound wildcard matching on adversarial inputs (#9486) Co-authored-by: Kuromi Co-authored-by: GatewayJ <835269233@qq.com> Co-authored-by: Hauser Zhi Co-authored-by: Chris An --- crates/policy/src/policy/utils/wildcard.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/policy/src/policy/utils/wildcard.rs b/crates/policy/src/policy/utils/wildcard.rs index 2e2f5459ec..9b0fea3157 100644 --- a/crates/policy/src/policy/utils/wildcard.rs +++ b/crates/policy/src/policy/utils/wildcard.rs @@ -230,6 +230,12 @@ mod tests { assert!(!is_simple_match("*🎉*🚀", "prefix🎉mid")); } + #[test] + fn test_question_mark_matches_bytes_not_unicode_scalars() { + assert!(!is_match("prefix?", "prefix界")); + assert!(is_match("prefix???", "prefix界")); + } + /// Reference backtracking definition used only for small exhaustive equivalence checks. fn backtracking_match(pattern: &[u8], name: &[u8], simple: bool) -> bool { match pattern.split_first() {