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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to