Project

General

Profile

Bug #16922

Updated by shyouhei (Shyouhei Urabe) almost 4 years ago

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

Back