From 8e3a70d4b128fd92723a12a8a1184b87fc93586e Mon Sep 17 00:00:00 2001 From: Tim Allison Date: Tue, 18 Oct 2016 18:24:39 +0000 Subject: [PATCH] BUG 60273 -- Use codepageutil to get correct charset in VBAMacroReader git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1765490 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/poifs/macros/VBAMacroReader.java | 3 ++- .../poi/poifs/macros/TestVBAMacroReader.java | 10 ++++++++++ test-data/spreadsheet/60273.xls | Bin 0 -> 30208 bytes 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 test-data/spreadsheet/60273.xls diff --git a/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java b/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java index 21b535b104..42902d1311 100644 --- a/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java +++ b/src/java/org/apache/poi/poifs/macros/VBAMacroReader.java @@ -41,6 +41,7 @@ import org.apache.poi.poifs.filesystem.DocumentNode; import org.apache.poi.poifs.filesystem.Entry; import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; import org.apache.poi.poifs.filesystem.OfficeXmlFileException; +import org.apache.poi.util.CodePageUtil; import org.apache.poi.util.HexDump; import org.apache.poi.util.IOUtils; import org.apache.poi.util.RLEDecompressingInputStream; @@ -305,7 +306,7 @@ public class VBAMacroReader implements Closeable { break; case PROJECTCODEPAGE: int codepage = in.readShort(); - modules.charset = Charset.forName("Cp" + codepage); + modules.charset = Charset.forName(CodePageUtil.codepageToEncoding(codepage, true)); break; case STREAMNAME: streamName = readString(in, recordLength, modules.charset); diff --git a/src/testcases/org/apache/poi/poifs/macros/TestVBAMacroReader.java b/src/testcases/org/apache/poi/poifs/macros/TestVBAMacroReader.java index a001ad9896..df90c8f444 100644 --- a/src/testcases/org/apache/poi/poifs/macros/TestVBAMacroReader.java +++ b/src/testcases/org/apache/poi/poifs/macros/TestVBAMacroReader.java @@ -272,4 +272,14 @@ public class TestVBAMacroReader { assertNotNull(macros.get("NewMacros")); assertContains(macros.get("NewMacros"), "' dirty"); } + + @Test + public void bug60273() throws IOException { + //test file derives from govdocs1 147240.xls + File f = POIDataSamples.getSpreadSheetInstance().getFile("60273.xls"); + VBAMacroReader r = new VBAMacroReader(f); + Map macros = r.readMacros(); + assertNotNull(macros.get("Module1")); + assertContains(macros.get("Module1"), "9/8/2004"); + } } diff --git a/test-data/spreadsheet/60273.xls b/test-data/spreadsheet/60273.xls new file mode 100644 index 0000000000000000000000000000000000000000..07933cff6fa9935172d8165b02c9bd8f4d6d9d63 GIT binary patch literal 30208 zcmeHw30zah_V6SG2&+U8apejqD2oXon<7g{T7`|8@-eCOPo8^>ftMhw zA2gm7fB?W60NdOaKnP$5U=QE`;0WLZ;0(|L091g809pdL0=NOR0&oXt4d4OL2B0lK zJAn289RNB4cmhxWodCQ5ya9XwIsY=;)!#w~X5FiMkJAfEK0uT%k0uTxi z1`r7l4iEu=JP`gDOxHjLQNo`Z+9HvZ!d*qiL#;JGxP!*9ocWN965^GRI{Hfb;BC)! z<;RMyr+9V5%X2i`y8*5al>)*L$X!K>NDeJW5rceLWd~04DD6N9XNHG|oe<$@JHgDC}SR{Vad_6$*%u^48L3bo5GyF3l zvj7aPd8#GOt3VuGZ8VXp8!3eB!f4JQb4w?ll&&WQbaAXRilo4`fE0qUk-$(80A&ax zx)Qdu<;2Dqf>*}40421{;{r%5(#vEj7mVTd${4*~8Kd_rV(>_e#nNI~LSGRBhdNpp zp?*!5g$Dz-r8>pZ+FRhk(dm}P8sCvzfTnG2Aw9<6fkAwg40f;JfkxF_NjnPK!{7rG z4KE)r?*MOaady|9BmCHx5nVe9I>A&1CLJsa=)*JQc_WP@dBI!8uS?+LMoP!YGCa z;*J6#S&P$1c2Rn!ztKgI{R| z|A`s=Ml*PG@+>wJ|5Gz~bNre3=)}-^qOTt&ep5UnPg6W2PgA@({-4ouHjV$48N9jp z+swrO(hUA{Gx$Ab@Qgg@5E|FdCOW(8fe4s-Ku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