Skip to content

Commit

Permalink
AO3-6864 Disallow URLs followed by something else in CSS (otwcode#4992)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilka2 authored Dec 15, 2024
1 parent 1375d27 commit ab948f3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/css_cleaner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def sanitize_css_content(value)
return value if value =~ /^\"([^\"]*)\"$/

# or a valid img url
return value if value.match(URL_FUNCTION_REGEX)
return value if value.match(Regexp.new("^#{URL_FUNCTION_REGEX}$"))

# or "none"
return value if value == "none"
Expand Down
3 changes: 2 additions & 1 deletion spec/models/skin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@
"errors when saving gradient with xss" => "div {background: -webkit-linear-gradient(url(xss.htc))}",
"errors when saving dsf images" => "body {background: url(http://foo.com/bar.dsf)}",
"errors when saving urls with invalid domain" => "body {background: url(http://foo.htc/bar.png)}",
"errors when saving xss interrupted with comments" => "div {xss:expr/*XSS*/ession(alert('XSS'))}"
"errors when saving xss interrupted with comments" => "div {xss:expr/*XSS*/ession(alert('XSS'))}",
"errors when saving url followed by something else" => 'a {content: url(/images/fakeimage.png) " (" attr(href) ")"}'
}.each_pair do |condition, css|
it condition do
@skin.css = css
Expand Down

0 comments on commit ab948f3

Please sign in to comment.