Skip to content

iframe are scrubbed by default? #109

Closed
@paul-mesnilgrente

Description

@paul-mesnilgrente

Raising this issue as I feel like it's a bug, or maybe a lack of documentation.

I ran a script to remove all the inline styles from the database. And it turned out that it removed all the iframes as well. Here's a summary of it

scrubber = Rails::Html::TargetScrubber.new
scrubber.attributes = ['style']

html_with_iframe = '<iframe style="display: none" width="1231" height="699" src="https://www.youtube.com/embed/abcd"></iframe>'
html_fragment = Loofah.fragment(html_with_iframe)
html_fragment.scrub!(scrubber) # scrubbed the iframe
new_html = html_fragment.to_s # empty string

To make this work, I actually have to tell the scrubber to not scrub any tags with scrubber.tags = [] even if scrubber.tags returns nil after the initialization.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions