File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ def call
111
111
# hash to the filter but defaults to WHITELIST constant value above.
112
112
def whitelist
113
113
whitelist = ( context [ :whitelist ] || WHITELIST ) . dup
114
- whitelist [ :protocols ] = whitelist [ :protocols ] . dup
114
+ whitelist [ :protocols ] = ( whitelist [ :protocols ] || { } ) . dup
115
115
whitelist [ :protocols ] [ 'a' ] = ( whitelist [ :protocols ] [ 'a' ] || { } ) . merge ( 'href' => anchor_schemes )
116
116
whitelist
117
117
end
Original file line number Diff line number Diff line change @@ -77,6 +77,13 @@ def test_anchor_schemes_are_merged_with_other_anchor_restrictions
77
77
assert_equal '<a href="something-weird://heyyy">Wat</a> is this' , html
78
78
end
79
79
80
+ def test_whitelist_from_full_constant
81
+ stuff = '<a href="something-weird://heyyy" ping="more-weird://hiii">Wat</a> is this'
82
+ filter = SanitizationFilter . new ( stuff , :whitelist => SanitizationFilter ::FULL )
83
+ html = filter . call . to_s
84
+ assert_equal 'Wat is this' , html
85
+ end
86
+
80
87
def test_script_contents_are_removed
81
88
orig = '<script>JavaScript!</script>'
82
89
assert_equal "" , SanitizationFilter . call ( orig ) . to_s
You can’t perform that action at this time.
0 commit comments