Skip to content

Commit c912d6d

Browse files
committed
Strip contents of <script> tags. Fixes feedbin/support#49.
1 parent 0cd6136 commit c912d6d

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/html/pipeline/sanitization_filter.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class SanitizationFilter < Filter
3535
div ins del sup sub p ol ul table blockquote dl dt dd
3636
kbd q samp var hr ruby rt rp li tr td th
3737
),
38+
:remove_contents => ['script'],
3839
:attributes => {
3940
'a' => ['href'],
4041
'img' => ['src'],

test/html/pipeline/sanitization_filter_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,9 @@ def test_github_specific_protocols_are_not_removed
4444
stuff = '<a href="github-windows://spillthelog">Spill this yo</a> and so on'
4545
assert_equal stuff, SanitizationFilter.call(stuff).to_s
4646
end
47+
48+
def test_script_contents_are_removed
49+
orig = '<script>JavaScript!</script>'
50+
assert_equal "", SanitizationFilter.call(orig).to_s
51+
end
4752
end

0 commit comments

Comments
 (0)