dart-neats icon indicating copy to clipboard operation
dart-neats copied to clipboard

Extend sanitize

Open kascote opened this issue 3 years ago • 1 comments

This PR extends sanitize_html to allow custom tags and attributes.

  • Two new callbacks handle the checks
  • The internal functions were normalized using the same parameters as the callbacks.
  • Test added to check for the new functionality
  • There are no changes to how the library worked before and do not require code changes.

An upcoming PR will handle the remove_contents option as observed on https://github.com/google/dart-neats/issues/101

kascote avatar Apr 14 '22 23:04 kascote

lol, I just saw the old comment in https://github.com/google/dart-neats/issues/101#issuecomment-789717870 :rofl:

hmm, ...maybe, I'm should be more open to signatures like:

  • bool allowTag(String tag), and,
  • bool allowAttribute(String tag, String attribute, String value)

Context: I use this library for sanitizing markdown on pub.dev, and I want that to be consistent with how it renders on github. But yeah, I can also see the value with allowing a few tweaks.. we did that for adding ugc attributes to links.

jonasfj avatar Apr 29 '22 14:04 jonasfj