Skip to content

Commit

Permalink
Merge pull request #276 from felixbuenemann/fix-invalid-xml-char-esca…
Browse files Browse the repository at this point in the history
…ping

Fix invalid XML escaping of U+10000 to U+10FFFF character range
  • Loading branch information
weshatheleopard committed Oct 31, 2017
2 parents 5adc421 + f259f28 commit 30f818f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rubyXL/objects/text.rb
Expand Up @@ -14,7 +14,7 @@ class Text < OOXMLObject
# http://www.w3.org/TR/REC-xml/#NT-Char:
# Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]

INVALID_XML10_CHARS = /([^\x09\x0A\x0D\x20-\uD7FF\uE000-\uFFFD\u10000-\u10FFFF])/
INVALID_XML10_CHARS = /([^\x09\x0A\x0D\x20-\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}])/
ESCAPED_UNICODE = /_x([0-9A-F]{4})_/

def before_write_xml
Expand Down
8 changes: 8 additions & 0 deletions spec/lib/text_spec.rb
Expand Up @@ -16,6 +16,14 @@
expect(str).to be
end

it 'should not escape valid XML extended UNICODE characters' do
t = RubyXL::Text.new(:value => "\u{10000}\u{10FFFF}")

xml = t.write_xml[/<t>[^<]+<\/t>/]

expect(xml).to eq("<t>\u{10000}\u{10FFFF}</t>")
end

end

end

0 comments on commit 30f818f

Please sign in to comment.