Skip to content

Conversation

@cuong-mudah
Copy link

This pull request introduces a new option to the HTML sanitizer policy, allowing for more flexible handling of unsafe text content. The main change is the addition of the AllowUnsafeText feature, which lets users control whether raw text in HTML is sanitized or left as-is. This is accompanied by updates to the sanitizer logic and new tests to verify the behavior.

New Feature: Allow Unsafe Text

  • Added allowUnsafeText field to the Policy struct to track the new option.
  • Implemented the AllowUnsafeText method in Policy, enabling users to set the option via the API.

Sanitization Logic Update

  • Updated the sanitize function to conditionally write raw text or escape it, based on the value of allowUnsafeText.

Testing

  • Added TestAllowUnsafeText to policy_test.go to verify that the sanitizer behaves correctly when the new option is enabled, ensuring unsafe tags are removed and text is handled as expected.

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.

2 participants