Permalink
Browse files

escape html to support <,>, etc

  • Loading branch information...
1 parent 3114145 commit a1005565f4e7c0a5a16ce77119c88ef73591afe9 Hugh Mcgowan committed Jan 30, 2009
Showing with 17 additions and 4 deletions.
  1. +3 −3 lib/roo/openoffice.rb
  2. +1 −1 test/no_spreadsheet_file.txt
  3. +13 −0 test/test_roo.rb
View
@@ -5,6 +5,7 @@
require 'zip/zipfilesystem'
require 'date'
require 'base64'
+require 'cgi'
class Openoffice < GenericSpreadsheet
@@ -304,9 +305,8 @@ def read_cells(sheet=nil)
str_v = str_v + child.to_s #.text
}
end
- str_v.gsub!(/&quot;/,'"')
- str_v.gsub!(/&amp;/,'&')
- str_v.gsub!(/&apos;/,"'")
+ str_v.gsub!(/&apos;/,"'") # special case not supported by unescapeHTML
+ str_v = CGI.unescapeHTML(str_v)
end # == 'p'
end
elsif vt == 'time'
@@ -1 +1 @@
-this is intionally not a spreadsheet file
+this is intentionally not a spreadsheet file
View
@@ -4830,4 +4830,17 @@ def SKIP_test_bug_encoding_exported_from_google
assert_equal 'test', xl.cell(2,'F')
end
end
+
+ def test_cell_openoffice_html_escape
+ if OPENOFFICE
+ oo = Openoffice.new(File.join("test","html-escape.ods"))
+ oo.default_sheet = oo.sheets.first
+ assert_equal "'", oo.cell(1,1)
+ assert_equal "&", oo.cell(2,1)
+ assert_equal ">", oo.cell(3,1)
+ assert_equal "<", oo.cell(4,1)
+ assert_equal "`", oo.cell(5,1)
+ # test_openoffice_zipped catches the &quot;
+ end
+ end
end # class

0 comments on commit a100556

Please sign in to comment.