Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting false "Secured pdf file are currently not supported." #488

Closed
parijke opened this issue Nov 19, 2021 · 10 comments
Closed

Getting false "Secured pdf file are currently not supported." #488

parijke opened this issue Nov 19, 2021 · 10 comments
Labels
bug missing or incomplete functionality For something which is not a bug, but more like an incomplete feature.

Comments

@parijke
Copy link

parijke commented Nov 19, 2021

I have a PDF that, when trying to parse the parser says
Secured pdf file are currently not supported.

image

Sounds like a false positive to me?

@k00ni
Copy link
Collaborator

k00ni commented Nov 19, 2021

Can you provide us the PDF? We would like to include it in our test environment, therefore it must be free of charge and without any obligations.

@k00ni k00ni added bug missing or incomplete functionality For something which is not a bug, but more like an incomplete feature. PDF required to demonstrate issue labels Nov 19, 2021
@parijke
Copy link
Author

parijke commented Nov 21, 2021

I've looked into it. If I comment out line 102 - 104 in the Parser, the file get parsed. The problem is, that the trailer HAS a reference to /Encrypt:

here's the trailer:

trailer

<<
/Encrypt 17 0 R
/Info 18 0 R
/Root 16 0 R
/Size 19
/ID [<8f6e73e43f6fc457c6d42783e4005ec4><624b2ff302bbf94e2e0f53c90933b5c1>]
>>
startxref
28499
%%EOF

/Encrypt [dictionary]: Specifies the document’s encryption dictionary.

But is does not use it. The file is not encrypted. Or at least I can use getText() on it and get the contents?

So testing a pdf on the value encrypt is not fail safe to really test for secured files. Or if I misunderstood, secured files can be read.

To replicate:

try {
    $pdf = $parser->parseFile($directory.'/'.$file);

} catch (Exception $e) {
    $text = $pdf->getText();
    echo $text;
}

@parijke
Copy link
Author

parijke commented Nov 21, 2021

test.pdf

Here's an example file. I created it using LibreOffice. While exporting to PDF, I set the WRITE password, but not the READ password.

So it is not encrypted for reading, which is the case in the file I encountered this at first as well.

Now you have a test file

@k00ni
Copy link
Collaborator

k00ni commented Nov 22, 2021

Thank you for your detailed feedback. I hope someone can pick up the ball and writes a fix.

@parijke
Copy link
Author

parijke commented Nov 22, 2021

@parijke
Copy link
Author

parijke commented Nov 23, 2021

@EthosLuke
Copy link

Any progress on this?

@pedroponte
Copy link

+1 any update please?

@k00ni
Copy link
Collaborator

k00ni commented Jan 11, 2023

Not to my knowledge, sorry.

@k00ni
Copy link
Collaborator

k00ni commented Dec 1, 2023

#653 should provide a valid work around until there is a better solution/fix.

@k00ni k00ni closed this as completed Dec 1, 2023
k00ni added a commit that referenced this issue Dec 1, 2023
* Add ability to ingore PDF encryption check

* Switch to ! syntax

* Update src/Smalot/PdfParser/Parser.php

* Additional changes for #488

doc/Usage.md:

  - Moved description of `setIgnoreEncryption` option to doc/CustomConfig.md
  - Added brief "PDF encryption" section

doc/CustomConfig.md: added `setIgnoreEncryption` option and section to describe it.

src/Smalot/PdfParser/Config.php: Doc comment for Config::setIgnoreEncryption()

Added tests/PHPUnit/Integration/EncryptionTest.php

Added samples/not_really_encrypted.pdf (thanks to @parijke who
orginially created this as test.pdf)

See #653

* src/Smalot/PdfParser/Config.php: PHP-CS-Fixer issue fixed

* Update CustomConfig.md

refined texts

* Config.php: use explicit PHP doc entities

* ParserTest.php: moved tests

* removed EncryptionTest.php

---------

Co-authored-by: Jordan Hall <[email protected]>
Co-authored-by: Konrad Abicht <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug missing or incomplete functionality For something which is not a bug, but more like an incomplete feature.
Projects
None yet
Development

No branches or pull requests

4 participants