You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2012/08/17 16:48:12 UTC

[Bug 53734] New: Hyperlink parser does not accept URLs of type "javascript://"

https://issues.apache.org/bugzilla/show_bug.cgi?id=53734

          Priority: P2
            Bug ID: 53734
          Assignee: dev@poi.apache.org
           Summary: Hyperlink parser does not accept URLs of type
                    "javascript://"
          Severity: normal
    Classification: Unclassified
          Reporter: stefan.raubal@unycom.com
          Hardware: PC
            Status: NEW
           Version: 3.8
         Component: XSSF
           Product: POI

Created attachment 29247
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=29247&action=edit
Example Excel file that contains a single cell A1 that contains a hyperlink
with the URL "javascript://"

When creating a Workbook (org.apache.poi.ss.usermodel.Workbook internalWorkbook
= WorkbookFactory.create(inputStream)) an IllegalStateException is thrown if
the Excel docuemnt contains a hyperlink of the form "javascript://".

(Exception is thrown in method
org.apache.poi.xssf.usermodel.XSSFHyperlink.XSSFHyperlink(CTHyperlink,
PackageRelationship).)

Though this might sound like an exotic use casem it can occur frequently in our
web application when users copy & paste data from the Ajax GUI into a
spreadsheet.

But as in https://issues.apache.org/bugzilla/show_bug.cgi?id=52716 or
https://issues.apache.org/bugzilla/show_bug.cgi?id=53282 I really wonder why
the hyperlink handling is so strict (I wouldn't mind if an error or a warning
is logged, but throwing a runtime exception without giving a chance to control
or correct the situation is rather harsh.)

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 53734] Hyperlink parser does not accept URLs of type "javascript://"

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53734

Yegor Kozlov <ye...@dinom.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #1 from Yegor Kozlov <ye...@dinom.ru> ---
Fixed in r1402470. Please try with the latest build fro trunk.

Strictly speaking, MS Office generates a invalid OPC package because
"javascript://" is not a valid URI.
On the low level, POI uses java.net.URI to parse package relationships and this
is where the exception comes from.
The problem can be narrowed down to a single line:

new java.net.URI("javascript://");

which failes with "java.net.URISyntaxException: Expected authority at index 13:
javascript://" . 

The URI class is defined by RFC 2396 (http://www.ietf.org/rfc/rfc2396.txt) and
it requires that double slash must be immediately followed by the authority
component. 

I added a simple workaround: append a trailing slash if authority is missing,
e.g. "javascript:///". Java can parse such URIs without any problems.

Yegor

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 53734] Hyperlink parser does not accept URLs of type "javascript://"

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53734

Stefan Raubal <st...@unycom.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

-- 
You are receiving this mail because:
You are the assignee for the bug.

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