Project

General

Profile

Bug #16922

single quote should be escaped in xml

Added by lisbethw1130 (Lisbeth Wu) about 1 month ago. Updated about 1 month ago.

Status:
Open
Priority:
Normal
Target version:
-
ruby -v:
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
[ruby-core:98576]

Description

This is Lisbeth from Taiwan. I'm trying to convert a string to xml by using 'string'.encode(xml: :attr) but single quote doesn't escape as expected
Here's the spec shows which character needs to be escaped: https://www.w3.org/TR/xml/#dt-escape

and I found a more clean table in sitemap spec: https://www.sitemaps.org/protocol.html#escaping

Ampersand   &   &
Single Quote    '   '
Double Quote    "   "
Greater Than    >   >
Less Than   <   &lt;

expected output:

puts ':$+,;:=?@&\'"><'.encode(xml: :attr)

":$+,;:=?@&amp; **&apos;** &quot;&gt;&lt;"

real output:

":$+,;:=?@&amp; **'** &quot;&gt;&lt;"

Thanks for helping

#1

Updated by shyouhei (Shyouhei Urabe) about 1 month ago

  • Description updated (diff)

Updated by jeremyevans0 (Jeremy Evans) about 1 month ago

  • Assignee set to akr (Akira Tanaka)

I've added a pull request to escape ' as &apos;: https://github.com/ruby/ruby/pull/3177

akr (Akira Tanaka), can you let me know if this is correct?

Also available in: Atom PDF