Copilot commented on code in PR #3072:
URL: https://github.com/apache/tika/pull/3072#discussion_r3860805256


##########
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/JackcessParser.java:
##########
@@ -114,9 +114,18 @@ public void parse(TikaInputStream tis, ContentHandler 
handler, Metadata metadata
                         "Jackcess doesn't process mdb versions before v97");
             }
             throw e;
+        } catch (IndexOutOfBoundsException e) {
+            // TIKA-4830
+            throw new CorruptedFileException(e.getMessage(), e);

Review Comment:
   `CorruptedFileException` is referenced here but isn’t imported in this file, 
so this will not compile. Either add `import 
org.apache.tika.exception.CorruptedFileException;` or use the fully-qualified 
class name.
   
   This issue also appears on line 127 of the same file.



##########
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/JackcessParser.java:
##########
@@ -114,9 +114,18 @@ public void parse(TikaInputStream tis, ContentHandler 
handler, Metadata metadata
                         "Jackcess doesn't process mdb versions before v97");
             }
             throw e;
+        } catch (IndexOutOfBoundsException e) {
+            // TIKA-4830
+            throw new CorruptedFileException(e.getMessage(), e);
         } catch (IllegalStateException e) {
-            if (e.getMessage() != null && e.getMessage().contains("Incorrect 
password")) {
-                throw new EncryptedDocumentException(e);
+            if (e.getMessage() != null) {
+                if (e.getMessage().contains("Incorrect password")) {
+                    throw new EncryptedDocumentException(e);
+                }
+                if (e.getMessage().startsWith("invalid page number ")) {
+                    // TIKA-4830
+                    throw new CorruptedFileException(e.getMessage(), e);
+                }

Review Comment:
   New exception-mapping behavior is being added here (treating certain 
`IndexOutOfBoundsException` / `IllegalStateException` messages as corruption), 
but `JackcessParserTest` currently only covers basic parsing, password 
handling, and metadata. Please add a regression test that exercises one of 
these failure modes and asserts `CorruptedFileException` is thrown (likely 
requiring a deliberately malformed .mdb/.accdb test resource).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to