fix(html): check link schemes the way browsers read them
FastSanitize checks the scheme with URI.parse/1, which finds none in java<TAB>script:alert(1). Browsers remove tabs and newlines and leading control characters first and run it as a javascript: link. The scrubbers now use Pleroma.HTML.URIAttributes, which normalizes the URL the same way before the scheme check.
This commit is contained in:
parent
58d4f6aa2c
commit
1be50ed28b
6 changed files with 95 additions and 5 deletions
|
|
@ -10,12 +10,13 @@ defmodule Pleroma.HTML.Scrubber.LinksOnly do
|
|||
@valid_schemes Pleroma.Config.get([:uri_schemes, :valid_schemes], [])
|
||||
|
||||
require FastSanitize.Sanitizer.Meta
|
||||
require Pleroma.HTML.URIAttributes
|
||||
alias FastSanitize.Sanitizer.Meta
|
||||
|
||||
Meta.strip_comments()
|
||||
|
||||
# links
|
||||
Meta.allow_tag_with_uri_attributes(:a, ["href"], @valid_schemes)
|
||||
Pleroma.HTML.URIAttributes.allow_tag_with_uri_attributes(:a, ["href"], @valid_schemes)
|
||||
|
||||
Meta.allow_tag_with_this_attribute_values(:a, "rel", [
|
||||
"tag",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue