Miguel García created PDFBOX-2967:
-------------------------------------
Summary: OS font files with paths larger than 80 chars crash
FileSystemFontProvider
Key: PDFBOX-2967
URL: https://issues.apache.org/jira/browse/PDFBOX-2967
Project: PDFBox
Issue Type: Bug
Components: PDModel
Affects Versions: 2.0.0
Environment: Ubuntu Linux 12.04 amd64
Apache PDFBOX 2.0.0-20150803.050251-1602
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
Reporter: Miguel García
The {{org.apache.pdfbox.pdmodel.font.FileSystemFontProvider::saveCache()}}
method saves its cache in an instance of
{{Preferences.userNodeForPackage(FileSystemFontProvider.class)}}.
This {{java.util.prefs.Preferences}} class has a {{MAX_KEY_LENGTH = 80;}}
limit. The {{Preferences}} implementation we get for the
{{userNodeForPackage(...)}} method turns out to be an instance of
{{java.util.prefs.AbstractPreferences}}, which does respect this key length
limit and throws an IllegalArgumentException otherwise.
In my Linux environment I have some fonts under {{/usr/share/fonts}} with file
names longer than 80 characters. For example, those belonging to the
{{fonts-johnsmith-induni}} debian package.
Just by having these fonts installed, this problem happens and, for example,
things like lazyly, statically initialising the
{{org.apache.pdfbox.pdmodel.font.FontMapper.DefaultFontProvider.INSTANCE}}
fails leading to class loading problems.
May I (humbly!) suggest some solutions for the
{{org.apache.pdfbox.pdmodel.font.FileSystemFontProvider::saveCache()}} method.
- Not using {{Preferences}} for storing the cache.
- Avoiding to {{putByteArray(key, ...)}} into preferences anything with a key
longer than 80 chars (and outputting a warn log).
- Surrounding the {{putByteArray(key, ...)}} with a try-catch block for
IllegalArgument exception.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]