Skip to content

feat: add filterXSSWithResult to return removed elements - #299

Merged
leizongmin merged 2 commits into
masterfrom
trae/solo-agent-wM9oYx
May 6, 2026
Merged

feat: add filterXSSWithResult to return removed elements#299
leizongmin merged 2 commits into
masterfrom
trae/solo-agent-wM9oYx

Conversation

@leizongmin

Copy link
Copy Markdown
Owner

🎯 Changes

1. New filterXSSWithResult Function

  • Introduce filterXSSWithResult function that returns an object { html: String, removed: Array }.
  • The removed array contains detailed information about ignored tags and attributes.
  • Records removed tags with type "tag", tag name, HTML content, and isClosing flag.
  • Records removed attributes with type "attr", tag name, attribute name, and attribute value.
  • Preserves user-defined onIgnoreTag and onIgnoreTagAttr hooks while recording removals.

2. Documentation Updates

  • Update README.md with usage examples for filterXSSWithResult.
  • Update README.zh.md with Chinese documentation for the new function.

3. Testing

  • Add comprehensive test suite in test/test_filter_xss_with_result.js.
  • Tests cover removed tags, removed attributes, clean HTML, mixed dangerous inputs, user hook preservation, and options object immutability.

💡 Technical Highlights

  • Detailed Removal Tracking: Provides granular information on what was removed during XSS filtering.
  • Backward Compatibility: Integrates seamlessly with existing onIgnoreTag and onIgnoreTagAttr hooks.
  • Comprehensive Testing: Ensures robustness and correctness of the new functionality across various scenarios.

leizongmin and others added 2 commits May 6, 2026 08:05
Co-authored-by: traeagent <traeagent@users.noreply.github.com>
Co-authored-by: traeagent <traeagent@users.noreply.github.com>
@leizongmin
leizongmin merged commit 30c3ff8 into master May 6, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant