t3219: fix PCRE2 Unicode portability in prompt-injection-patterns.yaml#4693
t3219: fix PCRE2 Unicode portability in prompt-injection-patterns.yaml#4693alex-solovyev wants to merge 1 commit intomainfrom
Conversation
- Move _PG_YAML_PATTERNS_LOADED flag assignment to after successful parse+cache in _pg_load_yaml_patterns(); previously set after file discovery but before parsing, so a parse failure would permanently disable YAML loading on subsequent calls (transient failures treated as permanent) - Replace byte-level \xNN hex escapes in zero-width character YAML pattern with literal Unicode chars (U+200B ZWSP, U+200C ZWNJ, U+200D ZWJ, U+FEFF BOM) for portability across rg/grep/ggrep; byte-level escapes match individual bytes, not multi-byte UTF-8 codepoints Closes #3219
|
Important Review skippedAuto reviews are limited based on label configuration. 🚫 Review skipped — only excluded labels are configured. (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses two critical issues related to prompt injection pattern detection and YAML configuration loading. It enhances the robustness of zero-width character pattern matching by using native Unicode characters, ensuring consistent behavior across various regex engines. Additionally, it refines the logic for loading YAML patterns, preventing a scenario where a temporary parsing error could permanently disable the pattern loading mechanism for a session. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Sat Mar 14 07:22:43 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
There was a problem hiding this comment.
Code Review
This pull request introduces two important fixes. First, it corrects a faulty regex pattern in prompt-injection-patterns.yaml by replacing byte-level escapes with literal Unicode characters, ensuring zero-width characters are correctly detected across different tools. Second, it improves the robustness of the prompt-guard-helper.sh script by adjusting the logic to set a 'loaded' flag only after successfully parsing and caching YAML patterns. This prevents transient parse failures from permanently disabling the feature for a session. The changes are well-implemented and address the identified issues effectively. I have no further suggestions.
|
|
Duplicate of #4692 which was already merged. Closing. |



Summary
Addresses CodeRabbit review feedback from PR #2715 (issue #3219).
Two fixes:
YAML zero-width character pattern: Replace byte-level
\xNNhex escapes ([\xE2\x80\x8B\xE2\x80\x8C\xE2\x80\x8D\xEF\xBB\xBF]) with literal Unicode chars (U+200B ZWSP, U+200C ZWNJ, U+200D ZWJ, U+FEFF BOM). Byte-level escapes match individual bytes, not multi-byte UTF-8 codepoints — the pattern silently failed to match zero-width characters under all grep backends._PG_YAML_PATTERNS_LOADEDflag timing: Move flag assignment to after successful parse+cache in_pg_load_yaml_patterns(). Previously set after file discovery but before parsing, so a transient parse failure would permanently disable YAML loading for the session lifetime.Verification
rg,grep -P, andgrep -E(all handle UTF-8 natively)\x{...}PCRE2 code-point syntax confirmed working for\x{200B}etc. in inline patterns (separate from this fix)\p{Cyrillic}and\p{Greek}in inline patterns confirmed working with bothgrep -PandrgCloses #3219