Compare commits

...
This repository has been archived on 2019-05-14. You can view files and clone it, but cannot push or open issues or pull requests.

1 commit

Author SHA1 Message Date
Eugen Rochko d8298ba6d0 Fix #1870 - Strip control characters out of strings in AtomSerializer 2017-04-15 23:27:24 +02:00

View file

@ -311,11 +311,17 @@ class AtomSerializer
def append_element(parent, name, content = nil, attributes = {})
element = Ox::Element.new(name)
attributes.each { |k, v| element[k] = v.to_s }
element << content.to_s unless content.nil?
attributes.each { |k, v| element[k] = sanitize_str(v) }
element << sanitize_str(content) unless content.nil?
parent << element
end
def sanitize_str(raw_str)
str = raw_str.to_s
["\v", "\f", "\b"].each { |char| str = str.delete(char) }
str
end
def add_namespaces(parent)
parent['xmlns'] = TagManager::XMLNS
parent['xmlns:thr'] = TagManager::THR_XMLNS