Uploaded image for project: 'Tika'
  1. Tika
  2. TIKA-2432

Convert RTFParser's asserts to TikaExceptions

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.16
    • None
    • None
    • None

    Description

      The RTFParser relies on asserts in numerous places. With a fuzzed/corrupted file, the user will get an AssertionError rather than a TikaException.

      It looks like the idea in several places is to allow for the user to turn off assert-checking to allow for a lenient parser.

                  // In document
                  if (equals("b")) {
                      // b0
                      assert param == 0;
                      if (groupState.bold) {
      

      In other places, though, the assert checks for a showstopper.

          private void addOutputByte(int b) throws IOException, SAXException, TikaException {
              assert b >= 0 && b < 256 : "byte value out of range: " + b;
      

      It would be useful to distinguish between these. I propose adding a "beLenient" parameter (or something) to the RTFParser with default=true, that would ignore the first case if lenient, but would throw a TikaException if lenient=false. However, we'd always want to throw a TikaException for the second case.

      Attachments

        Activity

          People

            Unassigned Unassigned
            tallison Tim Allison
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: