pdfbox-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF subversion and git services (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (PDFBOX-4579) IndexOutOfBoundsException when setting DefaultFontProvider in FontMapper
Date Wed, 26 Jun 2019 15:52:00 GMT

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

ASF subversion and git services commented on PDFBOX-4579:
---------------------------------------------------------

Commit 1862151 from Tilman Hausherr in branch 'pdfbox/branches/issue4569'
[ https://svn.apache.org/r1862151 ]

PDFBOX-4579: avoid IndexOutOfBoundsException, as suggested by Joakim Nilsson

> IndexOutOfBoundsException when setting DefaultFontProvider in FontMapper
> ------------------------------------------------------------------------
>
>                 Key: PDFBOX-4579
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4579
>             Project: PDFBox
>          Issue Type: Bug
>          Components: FontBox, PDModel, Text extraction
>    Affects Versions: 2.0.15
>            Reporter: Joakim Nilsson
>            Priority: Major
>              Labels: easyfix
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> When parsing certain pdf's, I'm encountering an IndexOutOfBoundsException in WindowsFontDirFinder.java
on line 106:
> {code:java}
> psFontsDir = new File(windir.substring(0, 2) + File.separator + "PSFONTS");
> {code}
> WindowsFontDirFinder is used by the statement on line 128 in FontMapperImpl.java in my
case:
> {code:java}
> private static final FontProvider INSTANCE = new FileSystemFontProvider(fontCache);
> {code}
> The cause of the error is that the value of windir is "" (empty string), at least during
debugging in Windows. However, I should mention that parsing of the same document also fails
on ubuntu. While I don't know the exact mechanism of the failure on ubuntu, I assume it is
related.
> The code checks whether windir is null before doing the substring operation, but not
whether the length is in fact >2. I'm not sure why windir ends up being "" here, as the
windir env var is C:\WINDOWS.
>  
> A working fix for me was to change the windir null check on line 94 to:
> {code:java}
> if (windir != null && !windir.equals(""))
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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


Mime
View raw message