Apostrophe entity ' not handled properly #6

Closed
one-k opened this Issue Aug 24, 2011 · 3 comments

Comments

Projects
None yet
3 participants
@ghost

ghost commented Aug 24, 2011

The apostrophe (') gets converted into an ampersand and apos;

This test fails:

def test_ampersand_appos
data = Plist::parse_xml('Fish's Chips')
assert_equal("Fish's Chips", data)
end

I'm having trouble seeing where these entities are processed. If someone could point me in the right direction, I'd be happy to help.

J

I think this problem is happening on CGI::unescapeHTML. On my system that bug is in

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/cgi.rb (line 370):

string.gsub(/&(amp|quot|gt|lt|#[0-9]+|#x[0-9A-Fa-f]+);/n) do
match = $1.dup
case match
when 'amp' then '&'
when 'quot' then '"'
when 'gt' then '>'
when 'lt' then '<'

It's missing 'apos' in the regex.

And it also looks like this bug is part of Ruby 1.9.2 stdlib. (http://www.ruby-doc.org/stdlib/)

Collaborator

mattbrictson commented Apr 18, 2017

This seems to work fine as of Ruby 2.1 (which as of this writing is the oldest supported version of Ruby).

irb(main):001:0> plist = { "key" => "Val'ue" }.to_plist
=> "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>key</key>\n\t<string>Val&#39;ue</string>\n</dict>\n</plist>\n"
irb(main):002:0> Plist.parse_xml _
=> {"key"=>"Val'ue"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment