git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1402470 13f79535-47bb-0310-9956-ffa450edef68tags/3.10-beta1
@@ -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> |
@@ -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); | |||
} | |||
@@ -123,7 +123,8 @@ public class TestPackagingURIHelper extends TestCase { | |||
"..\\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 extends TestCase { | |||
} | |||
} | |||
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()); | |||
} | |||
} |
@@ -243,4 +243,13 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink { | |||
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()); | |||
} | |||
} |