From 4a5e1574ca3488cc0dc6610361ca99eb9ab3020f Mon Sep 17 00:00:00 2001 From: Matthias Neeracher Date: Fri, 26 Aug 2011 17:02:20 +0000 Subject: [PATCH] Properly handle XML entities on reading (Tracker #3284508) --- Filters/plistWriter.rb | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Filters/plistWriter.rb b/Filters/plistWriter.rb index ab231ac..b85b0dc 100644 --- a/Filters/plistWriter.rb +++ b/Filters/plistWriter.rb @@ -16,15 +16,26 @@ class PlistData end def _encodeEntities(string) - encoded = [] + encoded = '' string.unpack('U*').each do |ch| - if ch <= 0x7F + case ch + when 0x22 + encoded.concat('"') + when 0x26 + encoded.concat('&') + when 0x27 + encoded.concat(''') + when 0x3C + encoded.concat('<') + when 0x3E + encoded.concat('>') + when 0..0x7F encoded << ch else - encoded.concat("&\##{ch};".unpack('C*')) + encoded.concat("&\##{ch};") end end - encoded.pack('C*') + encoded end def _encodePlist(destination, object, indent)