Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML::Builder can write invalid XML characters #4089

Closed
RX14 opened this issue Feb 28, 2017 · 1 comment
Closed

XML::Builder can write invalid XML characters #4089

RX14 opened this issue Feb 28, 2017 · 1 comment
Assignees
Labels
help wanted This issue is generally accepted and needs someone to pick it up kind:bug topic:stdlib

Comments

@RX14
Copy link
Contributor

RX14 commented Feb 28, 2017

On crystal 0.21.0

# example.cr
require "xml"

xml = XML.build(indent: 2) do |xml|
  xml.element("example", number: "1") do
    xml.text "foo\0bar"
  end
  xml.element("example", number: "2") do
    xml.text "foo\u{08}bar"
  end
end

puts xml
$ crystal example.cr
<?xml version="1.0"?>
<example number="1">foo</example>
<example number="2">fobar</example>

I expect to see XML::Builder raise, because NUL and DEL cannot be represented in XML. (ref)

@asterite asterite added kind:bug status:discussion topic:stdlib help wanted This issue is generally accepted and needs someone to pick it up and removed status:discussion labels Mar 2, 2017
@asterite
Copy link
Member

asterite commented Mar 2, 2017

Good finding! We should use xmlEncodeSpecialChars, both for texts and attributes, I guess. Nokogiri seems to use that function too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted This issue is generally accepted and needs someone to pick it up kind:bug topic:stdlib
Projects
None yet
Development

No branches or pull requests

2 participants