You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Axel Howind (Jira)" <ji...@apache.org> on 2023/09/04 07:53:00 UTC

[jira] [Created] (PDFBOX-5672) PDFToImage might not correctly detect unsupported image formats

Axel Howind created PDFBOX-5672:
-----------------------------------

             Summary: PDFToImage might not correctly detect unsupported image formats
                 Key: PDFBOX-5672
                 URL: https://issues.apache.org/jira/browse/PDFBOX-5672
             Project: PDFBox
          Issue Type: Bug
            Reporter: Axel Howind
         Attachments: fix_detection_of_unsupported_image_file_formats.patch

PDFToImage contains this code:

{code:java}
        if (getImageFormats().indexOf(imageFormat) == -1)
        {
            SYSERR.println( "Error: Invalid image format " + imageFormat + " - supported are: " + getImageFormats());
            return 2;
        }
{code}
 Here, `getImageFormats()` is called to create a concatenated comma-separated string that contains all supported image formats. The problem is that a simple string search is carried out on the concatenated string. Imagine (hypothetical case) that "jpeg2000" is supported, but "jpeg" is not. If you pass in "jpeg", it will not be detected that the file format is unsupported.
The solution is to check to formats returned by ImageIO directly. At the same time, the `getImageFormats()`method can be replaced by a simple one-liner.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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