Revert "Upstream 20240517"

This commit is contained in:
KMY(雪あすか) 2024-05-24 08:15:12 +09:00 committed by GitHub
parent 9c006fd893
commit f6dec44e95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2347 changed files with 26470 additions and 87494 deletions

View file

@ -55,29 +55,6 @@ class Sanitize
current_node.replace(Nokogiri::XML::Text.new(current_node.text, current_node.document)) unless LINK_PROTOCOLS.include?(scheme)
end
PHISHING_SCAM_HREF_TRANSFORMER = lambda do |env|
return unless env[:node_name] == 'a'
current_node = env[:node]
href = current_node['href'] || ''
text = current_node.text
cls = current_node['class'] || ''
dot_pos = text.index('.')
return unless dot_pos.present? && dot_pos.positive? && dot_pos < text.size - 1
scheme = if href =~ Sanitize::REGEX_PROTOCOL
Regexp.last_match(1).downcase
else
:relative
end
if LINK_PROTOCOLS.include?(scheme) && href != text && href != "https://#{text}" && !text.start_with?('#') && !text.start_with?('@')
current_node['class'] = "#{cls} kmy-dangerous-link"
current_node.before(Nokogiri::XML::Text.new('⚠', current_node.document))
end
end
UNSUPPORTED_ELEMENTS_TRANSFORMER = lambda do |env|
return unless %w(h1 h2 h3 h4 h5 h6).include?(env[:node_name])
@ -111,7 +88,6 @@ class Sanitize
TRANSLATE_TRANSFORMER,
UNSUPPORTED_ELEMENTS_TRANSFORMER,
UNSUPPORTED_HREF_TRANSFORMER,
PHISHING_SCAM_HREF_TRANSFORMER,
]
)