Fix #1870 - Strip control characters out of strings in AtomSerializer
This commit is contained in:
parent
00392d3c63
commit
d8298ba6d0
|
@ -311,11 +311,17 @@ class AtomSerializer
|
||||||
|
|
||||||
def append_element(parent, name, content = nil, attributes = {})
|
def append_element(parent, name, content = nil, attributes = {})
|
||||||
element = Ox::Element.new(name)
|
element = Ox::Element.new(name)
|
||||||
attributes.each { |k, v| element[k] = v.to_s }
|
attributes.each { |k, v| element[k] = sanitize_str(v) }
|
||||||
element << content.to_s unless content.nil?
|
element << sanitize_str(content) unless content.nil?
|
||||||
parent << element
|
parent << element
|
||||||
end
|
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)
|
def add_namespaces(parent)
|
||||||
parent['xmlns'] = TagManager::XMLNS
|
parent['xmlns'] = TagManager::XMLNS
|
||||||
parent['xmlns:thr'] = TagManager::THR_XMLNS
|
parent['xmlns:thr'] = TagManager::THR_XMLNS
|
||||||
|
|
Reference in a new issue