[
https://issues.apache.org/jira/browse/TIKA-1548?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14319372#comment-14319372
]
Tim Allison edited comment on TIKA-1548 at 2/13/15 1:21 AM:
------------------------------------------------------------
Fixed handling of bad passwords for encrypted pdfs. The PDFParser now throws
an {{EncryptedDocumentException}} like Tika's other parsers do for both the
classic and the non-sequential parser.
r1659446.
I used our current protected pdf for the new unit tests.
However, I confirmed that [~dadoonet]'s {{testSystem()}} unit test failed (in
RHEL) in the previous version of our {{PDFParser}} but now passes with the
fixes.
Thank you for reporting this and submitting a unit test with file!
was (Author: [email protected]):
Fixed handling of bad passwords for encrypted pdfs. The PDFParser now throws
an {{{EncryptedDocumentException}}} like Tika's other parsers do for both the
classic and the non-sequential parser.
r1659446.
I used our current protected pdf for the new unit tests.
However, I confirmed that the testSystem() unit test failed (in RHEL) in the
previous version of our PDFParser but now passes with the fixes.
> System property added while catching exception on parsing PDF encrypted doc
> ---------------------------------------------------------------------------
>
> Key: TIKA-1548
> URL: https://issues.apache.org/jira/browse/TIKA-1548
> Project: Tika
> Issue Type: Bug
> Components: parser
> Affects Versions: 1.7
> Environment: Mac OS 10.10.2
> java version "1.7.0_60"
> Reporter: David Pilato
> Fix For: 1.8
>
>
> I'm using Tika 1.7. I'm parsing an encrypted PDF document which raise an
> exception. So far, so good.
> My concern is that after that I have a new System property set
> {{sun.font.CFontManager}}.
> Code to reproduce the error:
> {code:java}
> @Test
> public void testSystem() {
> Properties props = System.getProperties();
> assertThat(props.get("sun.font.fontmanager"), nullValue());
> try {
> tika().parseToString(new
> URL("https://github.com/elasticsearch/elasticsearch-mapper-attachments/raw/master/src/test/resources/org/elasticsearch/index/mapper/xcontent/encrypted.pdf"));
> } catch (Throwable e) {
> }
> assertThat(props.get("sun.font.fontmanager"), nullValue());
> }
> {code}
> With Tika 1.7:
> {code}
> [2015-02-11 16:43:36,166][INFO ][org.apache.pdfbox.pdfparser.PDFParser]
> Document is encrypted
> [2015-02-11 16:43:36,837][ERROR][org.apache.pdfbox.filter.FlateFilter]
> FlateFilter: stop reading corrupt stream due to a DataFormatException
> [2015-02-11 16:43:36,837][ERROR][org.apache.pdfbox.filter.FlateFilter]
> FlateFilter: stop reading corrupt stream due to a DataFormatException
> [2015-02-11 16:43:36,838][ERROR][org.apache.pdfbox.filter.FlateFilter]
> FlateFilter: stop reading corrupt stream due to a DataFormatException
> [2015-02-11 16:43:36,838][ERROR][org.apache.pdfbox.filter.FlateFilter]
> FlateFilter: stop reading corrupt stream due to a DataFormatException
> [2015-02-11 16:43:36,839][ERROR][org.apache.pdfbox.filter.FlateFilter]
> FlateFilter: stop reading corrupt stream due to a DataFormatException
> [2015-02-11 16:43:36,840][ERROR][org.apache.pdfbox.filter.FlateFilter]
> FlateFilter: stop reading corrupt stream due to a DataFormatException
> [2015-02-11 16:43:36,840][ERROR][org.apache.pdfbox.filter.FlateFilter]
> FlateFilter: stop reading corrupt stream due to a DataFormatException
> [2015-02-11 16:43:36,841][ERROR][org.apache.pdfbox.filter.FlateFilter]
> FlateFilter: stop reading corrupt stream due to a DataFormatException
> [2015-02-11 16:43:36,841][ERROR][org.apache.pdfbox.filter.FlateFilter]
> FlateFilter: stop reading corrupt stream due to a DataFormatException
> [2015-02-11 16:43:36,842][ERROR][org.apache.pdfbox.filter.FlateFilter]
> FlateFilter: stop reading corrupt stream due to a DataFormatException
> java.lang.AssertionError:
> Expected: null
> but: was "sun.font.CFontManager"
> <Click to see difference>
> at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
> at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:8)
> at
> org.elasticsearch.plugin.mapper.attachments.test.TikaSystemTest.testSystem(TikaSystemTest.java:41)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
> at
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
> at
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
> at
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
> at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
> at
> com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
> at
> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
> at
> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
> {code}
> With Tika 1.6:
> {code}
> [2015-02-11 16:38:42,922][INFO ][org.apache.pdfbox.pdfparser.PDFParser]
> Document is encrypted
> {code}
> Note also that it logs a lot of errors which was not the case in Tika 1.6.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)