tika-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yauheni Salopiy (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (TIKA-1512) WordParser fails on many Word files
Date Thu, 26 Mar 2015 15:13:53 GMT

    [ https://issues.apache.org/jira/browse/TIKA-1512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14382010#comment-14382010
] 

Yauheni Salopiy edited comment on TIKA-1512 at 3/26/15 3:13 PM:
----------------------------------------------------------------

Hi,

I guess I found the cause of this error.
It's failing here (bold font):

         if((text.startsWith("HYPERLINK") || text.startsWith(" HYPERLINK"))
                 && text.indexOf('"') > -1) {
             *String url = text.substring(
                   text.indexOf('"') + 1,
                   text.lastIndexOf('"')*
             );
             xhtml.startElement("a", "href", url);
             for(CharacterRun cr : texts) {
                handleCharacterRun(cr, skipStyling, xhtml);
             }
             xhtml.endElement("a");
          } else {
            ...
          }

I have a number of such failing docs and some of hyperlinks looks like this:

HYPERLINK "http://www.accountingresearchmanager.com/wk/rm.nsf/0/7C2AE86AEDF358A1652577740025E00A?OpenDocument”
     (last quote *inclined*)
That's why we have here java.lang.*StringIndexOutOfBoundsException: String index out of range:
-1* for second quote.

I'm not sure whether such quotes are correct and is this content or code issue.
I think better solution here will be to replace inclined quotes before string snippet extraction:

*text.replace('”', '"');*
String url = text.substring(
                   text.indexOf('"') = -1 ?  + 1,
                   text.lastIndexOf('"')


Best Regards,
Yauheni Salopiy


was (Author: genstr):
Hi,

I guess I found the cause of this error.
It's failing here (bold font):

         if((text.startsWith("HYPERLINK") || text.startsWith(" HYPERLINK"))
                 && text.indexOf('"') > -1) {
             *String url = text.substring(
                   text.indexOf('"') + 1,
                   text.lastIndexOf('"')*
             );
             xhtml.startElement("a", "href", url);
             for(CharacterRun cr : texts) {
                handleCharacterRun(cr, skipStyling, xhtml);
             }
             xhtml.endElement("a");
          } else {
            ...
          }

I have a number of such failing docs and some of hyperlinks looks like this:

HYPERLINK "http://www.accountingresearchmanager.com/wk/rm.nsf/0/7C2AE86AEDF358A1652577740025E00A?OpenDocument”
     (last quote *inclined*)
That's why we have here java.lang.*StringIndexOutOfBoundsException: String index out of range:
-1* for second quote.

I'm not sure whether such quotes are correct and is this content or code issue.
I think better solution here will be to replace inclined quotes before string snippet extraction:

*
text.replace('”', '"');
String url = text.substring(
                   text.indexOf('"') = -1 ?  + 1,
                   text.lastIndexOf('"')
*

Best Regards,
Yauheni Salopiy

> WordParser fails on many Word files
> -----------------------------------
>
>                 Key: TIKA-1512
>                 URL: https://issues.apache.org/jira/browse/TIKA-1512
>             Project: Tika
>          Issue Type: Bug
>          Components: parser
>    Affects Versions: 1.5, 1.6, 1.7, 1.8
>         Environment: Linux 64bit
> OpenJDK Runtime Environment (IcedTea 2.4.4) (suse-24.13.5-x86_64)
> OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)
> and
> java version "1.6.0"
> Java(TM) SE Runtime Environment
> IBM J9 VM (build 2.4, JRE 1.6.0 IBM J9 2.4 Linux amd64-64 (JIT enabled, AOT enabled)
>            Reporter: F Seid
>            Assignee: Jukka Zitting
>
> WordParser fail on some word files. A negative value is sent to substring



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message