0
0
Fork 0

Fix #1972, fix #1870 - Fix special characters in XML, add tests (#1988)

Also improve efficiency of the mastodon:maintenance:add_static_avatars task
This commit is contained in:
Eugen 2017-04-17 19:58:54 +02:00 committed by GitHub
parent e43071a2f9
commit 15ec4ae07b
3 changed files with 6 additions and 8 deletions

View file

@ -3,13 +3,11 @@
class AtomSerializer
include RoutingHelper
INVALID_XML_CHARS = /[^\u0009\u000a\u000d\u0020-\uD7FF\uE000-\uFFFD\u10000-\u10FFFF]/
class << self
def render(element)
document = Ox::Document.new(version: '1.0')
document << element
('<?xml version="1.0"?>' + Ox.dump(element)).force_encoding('UTF-8')
('<?xml version="1.0"?>' + Ox.dump(element, effort: :tolerant)).force_encoding('UTF-8')
end
end
@ -319,7 +317,7 @@ class AtomSerializer
end
def sanitize_str(raw_str)
raw_str.to_s.gsub(INVALID_XML_CHARS, '')
raw_str.to_s
end
def add_namespaces(parent)