Skip to content

Commit

Permalink
Leniently parse ARC records containing corrupt dates
Browse files Browse the repository at this point in the history
Reported-by: @thomasegense
  • Loading branch information
ato committed Sep 15, 2023
1 parent eb28cfa commit 6c7083b
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 112 deletions.
12 changes: 12 additions & 0 deletions src/org/netpreserve/jwarc/MessageParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,20 @@
package org.netpreserve.jwarc;

import java.nio.ByteBuffer;
import java.util.function.Consumer;

public class MessageParser {
private Consumer<String> warningHandler;

protected void emitWarning(String message) {
if (warningHandler != null) {
warningHandler.accept(message);
}
}

void onWarning(Consumer<String> warningHandler) {
this.warningHandler = warningHandler;
}

protected static String getErrorContext(String input, int position, int length) {
StringBuilder context = new StringBuilder();
Expand Down
Loading

0 comments on commit 6c7083b

Please sign in to comment.