rrrene / html_sanitize_ex

HTML sanitizer for Elixir
MIT License
271 stars 62 forks source link

Allowed pattern is scrubbed #62

Open Awlexus opened 1 year ago

Awlexus commented 1 year ago

I need a similar scrubber as the ones seen in the documentation, but when I try to create and scrub some text it also scrubs the pattern I allowed.

# custom scrubber
defmodule LinksOnlyScrubber do
  require HtmlSanitizeEx.Scrubber.Meta
  alias HtmlSanitizeEx.Scrubber.Meta

  Meta.remove_cdata_sections_before_scrub()
  Meta.strip_comments()

  Meta.allow_tag_with_uri_attributes("a", ["href"], ["https", "mailto", "http"])

  Meta.strip_everything_not_covered()
end

Actual result

The tag has been removed

iex> HtmlSanitizeEx.Scrubber.scrub "This is a <a href=\"https://www.youtube.com/\">test</a>", LinksOnlyScrubber
"This is a test"

Expected result

The text should be left untouched

Versions

html_sanitize_ex 1.4.2 mochiweb 2.22.0