Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-5080

Type1Parser.parseASCII throws inconsistent exceptions

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.22
    • Fix Version/s: 2.0.23, 3.0.0 PDFBox
    • Component/s: None
    • Labels:
      None

      Description

      The code of this method is as follows:

        private void parseASCII(byte[] bytes) throws IOException
          {
              if (bytes.length == 0)
              {
                  throw new IllegalArgumentException("byte[] is empty");
              }        // %!FontType1-1.0
              // %!PS-AdobeFont-1.0
              if (bytes.length < 2 || (bytes[0] != '%' && bytes[1] != '!'))
              {
                  throw new IOException("Invalid start of ASCII segment");
              }
      ...
      }
      
      

      When length is zero, it throws IllegalArgumentException, but when length is below two and its contents are not as expected, it throws IOException. It looks strange. For me, in both cases, it shall throw IOException.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                tilman Tilman Hausherr
                Reporter:
                haozhong Hao Zhong
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: