[
https://issues.apache.org/jira/browse/PDFBOX-6313?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Tilman Hausherr updated PDFBOX-6313:
------------------------------------
Affects Version/s: 2.0.37
> PDEncryption.hasSecurityHandler() returns the inverse of what its javadoc says
> ------------------------------------------------------------------------------
>
> Key: PDFBOX-6313
> URL: https://issues.apache.org/jira/browse/PDFBOX-6313
> Project: PDFBox
> Issue Type: Bug
> Components: PDModel
> Affects Versions: 2.0.37, 3.0.8 PDFBox, 4.0.0
> Reporter: Martin Mirchev
> Priority: Major
>
> The javadoc says "Returns true if the security handler specified in the
> dictionary's Filter is available", but the method returns {{securityHandler
> == null}}:
> {code:java}
> public boolean hasSecurityHandler()
> {
> return securityHandler == null;
> }
> {code}
> So it is {{true}} when there is no handler and {{false}} when there is one:
> {code:java}
> new PDEncryption().hasSecurityHandler(); // true, no handler
> // RC4-128 document saved with StandardProtectionPolicy, then
> Loader.loadPDF(bytes, ""):
> doc.getEncryption().getSecurityHandler(); // StandardSecurityHandler
> doc.getEncryption().hasSecurityHandler(); // false
> {code}
> Checked on trunk (bd0c9c0); the same code is on the 3.0 and 2.0 branches.
> Nothing in PDFBox itself calls the method, so only API users are affected.
> The fix is {{return securityHandler != null;}}.
> This issue was found by an LLM-assisted tool and verified manually.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]