poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r1402470 - in /poi/trunk: src/documentation/content/xdocs/ src/ooxml/java/org/apache/poi/openxml4j/opc/ src/ooxml/testcases/org/apache/poi/openxml4j/opc/ src/ooxml/testcases/org/apache/poi/xssf/usermodel/ test-data/spreadsheet/
Date Fri, 26 Oct 2012 11:38:29 GMT
Author: yegor
Date: Fri Oct 26 11:38:28 2012
New Revision: 1402470

URL: http://svn.apache.org/viewvc?rev=1402470&view=rev
Log:
Bug #53374 Avoid exceptions when parsing hyperlinks of type 'javascript://'

Added:
    poi/trunk/test-data/spreadsheet/53734.xlsx   (with props)
Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackagingURIHelper.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=1402470&r1=1402469&r2=1402470&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Fri Oct 26 11:38:28 2012
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.9-beta1" date="2012-??-??">
+          <action dev="poi-developers" type="add">53374 - Avoid exceptions when parsing
hyperlinks of type "javascript://"</action>
           <action dev="poi-developers" type="add">53404 - Fixed compatibility bug with
modifying xls files created by POI-3.6 and earlier</action>
           <action dev="poi-developers" type="add">53979 - Support fetching properties
of Numbered Lists from PPT files</action>
           <action dev="poi-developers" type="add">53784 - Partial HSMF support for
fixed sized properties</action>

Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java?rev=1402470&r1=1402469&r2=1402470&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java Fri Oct
26 11:38:28 2012
@@ -21,6 +21,7 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.nio.ByteBuffer;
 import java.io.UnsupportedEncodingException;
+import java.util.regex.Pattern;
 
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
@@ -147,6 +148,8 @@ public final class PackagingURIHelper {
 		PACKAGE_ROOT_PART_NAME = tmpPACKAGE_ROOT_PART_NAME;
 	}
 
+    private static final Pattern missingAuthPattern = Pattern.compile("\\w+://");
+
 	/**
 	 * Gets the URI for the package root.
 	 *
@@ -706,6 +709,9 @@ public final class PackagingURIHelper {
             value = path + "#" + encode(fragment);
         }
 
+        if(missingAuthPattern.matcher(value).matches()){
+            value += "/";
+        }
         return new URI(value);
     }
 

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackagingURIHelper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackagingURIHelper.java?rev=1402470&r1=1402469&r2=1402470&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackagingURIHelper.java
(original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/openxml4j/opc/TestPackagingURIHelper.java
Fri Oct 26 11:38:28 2012
@@ -123,7 +123,8 @@ public class TestPackagingURIHelper exte
                 "..\\Program%20Files\\AGEIA%20Technologies\\v2.3.3\\NxCooking.dll",
                 "file:///D:\\seva\\1981\\r810102ns.mp3",
                 "..\\cygwin\\home\\yegor\\dinom\\%5baccess%5d.2010-10-26.log",
-                "#'Instructions (Text)'!B21"
+                "#'Instructions (Text)'!B21",
+                "javascript://"
         };
         for(String s : href){
             try {
@@ -134,4 +135,11 @@ public class TestPackagingURIHelper exte
         }
     }
 
+    public void test53734() throws Exception {
+        URI uri = PackagingURIHelper.toURI("javascript://");
+        // POI appends a trailing slash tpo avoid "Expected authority at index 13: javascript://"
+        // https://issues.apache.org/bugzilla/show_bug.cgi?id=53734
+        assertEquals("javascript:///", uri.toASCIIString());
+    }
+
 }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java?rev=1402470&r1=1402469&r2=1402470&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFHyperlink.java Fri
Oct 26 11:38:28 2012
@@ -243,4 +243,13 @@ public final class TestXSSFHyperlink ext
         assertEquals("B1", l2.getCellRef());
     }
 
+    public void test53734() {
+        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("53734.xlsx");
+        XSSFHyperlink link = wb.getSheetAt(0).getRow(0).getCell(0).getHyperlink();
+        assertEquals("javascript:///", link.getAddress());
+
+        wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
+        link = wb.getSheetAt(0).getRow(0).getCell(0).getHyperlink();
+        assertEquals("javascript:///", link.getAddress());
+    }
 }

Added: poi/trunk/test-data/spreadsheet/53734.xlsx
URL: http://svn.apache.org/viewvc/poi/trunk/test-data/spreadsheet/53734.xlsx?rev=1402470&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/test-data/spreadsheet/53734.xlsx
------------------------------------------------------------------------------
    svn:mime-type = application/vnd.ms-excel



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message