From 82331ab312935111217359b0a24cc20acaf9457e Mon Sep 17 00:00:00 2001 From: Rob Donnelly Date: Wed, 3 Feb 2021 13:08:02 -0800 Subject: Add test for special characters in pivot table cache definition --- test/workbook/worksheet/tc_pivot_table_cache_definition.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/workbook/worksheet/tc_pivot_table_cache_definition.rb b/test/workbook/worksheet/tc_pivot_table_cache_definition.rb index 282078b0..37d7e485 100644 --- a/test/workbook/worksheet/tc_pivot_table_cache_definition.rb +++ b/test/workbook/worksheet/tc_pivot_table_cache_definition.rb @@ -51,4 +51,12 @@ class TestPivotTableCacheDefinition < Test::Unit::TestCase assert(errors.empty?, "error free validation") end + def test_to_xml_string_for_special_characters + cell = @ws.rows.first.cells.first + cell.value = "&><'\"" + + doc = Nokogiri::XML(@cache_definition.to_xml_string) + errors = doc.errors + assert(errors.empty?, "invalid xml: #{errors.map(&:to_s).join(', ')}") + end end -- cgit v1.2.3 From fb7b437a2c75075c6ff99e441a0cf22428b2ebdc Mon Sep 17 00:00:00 2001 From: Rob Donnelly Date: Wed, 3 Feb 2021 13:08:22 -0800 Subject: Fix special characters in pivot table cache definition --- lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb b/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb index f136b663..969b0bf2 100644 --- a/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb +++ b/lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb @@ -53,7 +53,7 @@ module Axlsx str << '' str << ( '') pivot_table.header_cells.each do |cell| - str << ( '') + str << ( '') str << '' str << '' str << '' -- cgit v1.2.3