You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2021/01/06 23:14:46 UTC
svn commit: r1885215 - in /poi: site/src/documentation/content/xdocs/
trunk/src/scratchpad/src/org/apache/poi/hwmf/record/
trunk/src/scratchpad/testcases/org/apache/poi/hwmf/
trunk/test-data/slideshow/
Author: kiwiwings
Date: Wed Jan 6 23:14:45 2021
New Revision: 1885215
URL: http://svn.apache.org/viewvc?rev=1885215&view=rev
Log:
#65063 - WMF parsing failed on closed empty polygon
Added:
poi/trunk/test-data/slideshow/empty-polygon-close.wmf (with props)
Modified:
poi/site/src/documentation/content/xdocs/changes.xml
poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfDraw.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hwmf/TestHwmfParsing.java
Modified: poi/site/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/changes.xml?rev=1885215&r1=1885214&r2=1885215&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/changes.xml (original)
+++ poi/site/src/documentation/content/xdocs/changes.xml Wed Jan 6 23:14:45 2021
@@ -128,6 +128,7 @@
<action type="fix" fixes-bug="65026" context="POI_Overall">Migrate tests to Junit 5</action>
<action type="add" fixes-bug="github-207" context="POI_Overall">Use SLF4J instead of commons-logging - use jcl-over-slf4j</action>
<action type="fix" fixes-bug="65061" context="XSSF">Handle VmlDrawings containing spreadsheet-ml default namespace</action>
+ <action type="fix" fixes-bug="65063" context="HSLF">WMF parsing failed on closed empty polygon</action>
</actions>
</release>
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfDraw.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfDraw.java?rev=1885215&r1=1885214&r2=1885215&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfDraw.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfDraw.java Wed Jan 6 23:14:45 2021
@@ -143,10 +143,10 @@ public final class HwmfDraw {
@Override
public int init(LittleEndianInputStream leis, long recordSize, int recordFunction) throws IOException {
//A 16-bit signed integer that defines the number of points in the array.
- int numberofPoints = leis.readShort();
+ int numberOfPoints = leis.readShort();
- poly = new Path2D.Double(Path2D.WIND_EVEN_ODD, numberofPoints);
- for (int i=0; i<numberofPoints; i++) {
+ poly = new Path2D.Double(Path2D.WIND_EVEN_ODD, numberOfPoints);
+ for (int i=0; i<numberOfPoints; i++) {
// A 16-bit signed integer that defines the horizontal (x) coordinate of the point.
int x = leis.readShort();
// A 16-bit signed integer that defines the vertical (y) coordinate of the point.
@@ -158,12 +158,12 @@ public final class HwmfDraw {
}
}
- if (addClose()) {
+ if (numberOfPoints > 0 && addClose()) {
// polygons are closed / polylines not
poly.closePath();
}
- return LittleEndianConsts.SHORT_SIZE+numberofPoints*LittleEndianConsts.INT_SIZE;
+ return LittleEndianConsts.SHORT_SIZE+numberOfPoints*LittleEndianConsts.INT_SIZE;
}
@Override
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwmf/TestHwmfParsing.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwmf/TestHwmfParsing.java?rev=1885215&r1=1885214&r2=1885215&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwmf/TestHwmfParsing.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwmf/TestHwmfParsing.java Wed Jan 6 23:14:45 2021
@@ -39,6 +39,8 @@ import org.apache.poi.util.LocaleUtil;
import org.apache.poi.util.RecordFormatException;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
public class TestHwmfParsing {
@@ -48,12 +50,17 @@ public class TestHwmfParsing {
// for manual mass parsing and rendering tests of .wmfs use HemfPictureTest.paint() !
// ******************************************************************************
- @Test
- public void parse() throws IOException {
- try (InputStream fis = samples.openResourceAsStream("santa.wmf")) {
+ @ParameterizedTest
+ @CsvSource({
+ "santa.wmf, 581",
+ /* Bug 65063 */
+ "empty-polygon-close.wmf, 272"
+ })
+ public void parse(String file, int recordCnt) throws IOException {
+ try (InputStream fis = samples.openResourceAsStream(file)) {
HwmfPicture wmf = new HwmfPicture(fis);
List<HwmfRecord> records = wmf.getRecords();
- assertEquals(581, records.size());
+ assertEquals(recordCnt, records.size());
}
}
Added: poi/trunk/test-data/slideshow/empty-polygon-close.wmf
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/slideshow/empty-polygon-close.wmf?rev=1885215&view=auto
==============================================================================
Binary file - no diff available.
Propchange: poi/trunk/test-data/slideshow/empty-polygon-close.wmf
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org