0
0
Fork 0

Add translate="no" to outgoing mentions and links (#25524)

This commit is contained in:
Claire 2023-06-20 18:10:19 +02:00 committed by GitHub
parent 3a91603b15
commit c78280a8ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 4 deletions

View file

@ -36,6 +36,11 @@ class Sanitize
node['class'] = class_list.join(' ')
end
TRANSLATE_TRANSFORMER = lambda do |env|
node = env[:node]
node.remove_attribute('translate') unless node['translate'] == 'no'
end
UNSUPPORTED_HREF_TRANSFORMER = lambda do |env|
return unless env[:node_name] == 'a'
@ -63,8 +68,8 @@ class Sanitize
elements: %w(p br span a del pre blockquote code b strong u i em ul ol li),
attributes: {
'a' => %w(href rel class),
'span' => %w(class),
'a' => %w(href rel class translate),
'span' => %w(class translate),
'ol' => %w(start reversed),
'li' => %w(value),
},
@ -80,6 +85,7 @@ class Sanitize
transformers: [
CLASS_WHITELIST_TRANSFORMER,
TRANSLATE_TRANSFORMER,
UNSUPPORTED_ELEMENTS_TRANSFORMER,
UNSUPPORTED_HREF_TRANSFORMER,
]