| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
FilterInvisibleCharacters previously ran only before FilterHTMLTags, so numeric HTML entities (e.g. ​ or ​) that bluemonday decodes into invisible or bidirectional control characters could survive sanitization untouched. Sanitize now applies the invisible-character filter both before HTML processing (so raw invisible characters don't interfere with code-fence parsing) and again after, so entity-decoded characters cannot escape the policy. Also expands the removal set to include: - ARABIC LETTER MARK (U+061C), a directional format character in the same family as the already-covered LRM/RLM marks. - Variation selectors (U+FE00-U+FE0F) and the variation selectors supplement (U+E0100-U+E01EF), which can be used to hide payloads after emoji or other base characters. Fixes #3101
There was a problem hiding this comment.
Adds post-normalization invisible-Unicode filtering to prevent HTML entities bypassing sanitization.
Changes:
| File | Description |
|---|---|
| pkg/sanitize/sanitize.go | Updates sanitization order and removal ranges. |
| pkg/sanitize/sanitize_test.go | Adds entity-decoding and Unicode coverage. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Sorry, something went wrong.
Address review feedback on the post-HTML-entity sanitization pass. Entity decoding could still smuggle code-fence metadata past the sanitizer. A first line such as "`​``steal secrets" is not a fence in the raw input, so FilterCodeFenceMetadata left it alone; decoding the entity and stripping the zero width space then produced a real fence with its info string intact. Sanitize now re-runs the fence filter after the input is fully normalized. Filtering every variation selector also corrupted legitimate text: VS15 and VS16 select text or emoji presentation, so "✈️" was reduced to "✈", and the Variation Selectors Supplement encodes registered CJK ideographic variation sequences. Selectors are now filtered contextually. A selector is kept when it can apply to the character it follows, and dropped when it is orphaned, follows a removed or non-graphic character, or continues a run of selectors. Supplement selectors additionally require a CJK ideograph base, matching the Ideographic Variation Database. That keeps the anti-smuggling property, since hidden payloads rely on selector runs, without rewriting valid Unicode. Also corrects a lowercase-hex test case that claimed uppercase digits. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…-invisible-unicode-after-html-enti
| Back | FazBrowse Home | New Git URL |
Problem
FilterInvisibleCharacters only ran before FilterHTMLTags in Sanitize. FilterHTMLTags (bluemonday) decodes HTML character entities, so a numeric entity like ​ or ​ becomes a literal U+200B (zero width space) after the invisible-character pass already ran — letting encoded invisible/bidi characters survive sanitization untouched.
The removal set also omitted a couple of relevant format/variation-selector ranges.
Fix
These additions target characters commonly used for invisible-payload smuggling while leaving ordinary text, emoji, and CJK content untouched.
Testing
Fixes #3101
Acknowledgments
Thanks @Gal3m for the reports that led to this hardening.