Issue #16922 has been reported by lisbethw1130 (Lisbeth Wu). ---------------------------------------- Bug #16922: single quote should be escaped in xml https://bugs.ruby-lang.org/issues/16922 * Author: lisbethw1130 (Lisbeth Wu) * Status: Open * Priority: Normal * ruby -v: ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- 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 < < ``` expected output: > puts ':$+,;:=?@&\'"><'.encode(xml: :attr) ":$+,;:=?@& **'** "><" real output: > ":$+,;:=?@& **'** "><" Thanks for helping -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>