docbrown/app/sanitizers/feed_markdown_scrubber.rb
Daniel Uber a052b16015
Don't sanitize anchor elements with no href (#16667)
* If href is nil, allow node

* Add unit test showing no change

My first pass had the `<a>` within an h1 content, but the scrubber
added a newline after the closing a tag?
2022-02-22 11:27:38 -06:00

13 lines
366 B
Ruby

class FeedMarkdownScrubber < Rails::Html::PermitScrubber
def initialize
super
self.tags = MarkdownProcessor::AllowedTags::FEED
self.attributes = MarkdownProcessor::AllowedAttributes::FEED
end
def allowed_node?(node)
return true if tags.include?(node.name) && node.name != "a"
node.name == "a" && !node["href"]&.start_with?("#")
end
end