aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf <thomas.wolf@paranor.ch>2022-01-30 17:30:22 +0100
committerThomas Wolf <thomas.wolf@paranor.ch>2022-01-30 17:58:34 +0100
commit8bca5245e0585efb46ece2e3f5ec06a87cd808b6 (patch)
tree317925cdc8a3b2f8e5738e9c44c433a4634d9fd4
parent0fb5f47d2e8135721e1b5be9ee9e956af5330fc9 (diff)
downloadjgit-8bca5245e0585efb46ece2e3f5ec06a87cd808b6.tar.gz
jgit-8bca5245e0585efb46ece2e3f5ec06a87cd808b6.zip
BinaryHunkInputStream: accept CR-LF
Let's be lenient and accept hunk lines terminated by CR-LF, too, not just lines terminated by LF. Bug: 550111 Change-Id: I7f796df666300ab56cc6c07f22eda45fbf4c941e Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/io/BinaryHunkInputStream.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/BinaryHunkInputStream.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/BinaryHunkInputStream.java
index 4f940d77a0..2c972b578d 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/BinaryHunkInputStream.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/BinaryHunkInputStream.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 Thomas Wolf <thomas.wolf@paranor.ch> and others
+ * Copyright (C) 2021, 2022 Thomas Wolf <thomas.wolf@paranor.ch> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
@@ -90,7 +90,7 @@ public class BinaryHunkInputStream extends InputStream {
byte[] encoded = new byte[Base85.encodedLength(length)];
for (int i = 0; i < encoded.length; i++) {
int b = in.read();
- if (b < 0 || b == '\n') {
+ if (b < 0 || b == '\r' || b == '\n') {
throw new EOFException(MessageFormat.format(
JGitText.get().binaryHunkInvalidLength,
Integer.valueOf(lineNumber)));
@@ -99,6 +99,10 @@ public class BinaryHunkInputStream extends InputStream {
}
// Must be followed by a newline; tolerate EOF.
int b = in.read();
+ if (b == '\r') {
+ // Be lenient and accept CR-LF, too.
+ b = in.read();
+ }
if (b >= 0 && b != '\n') {
throw new StreamCorruptedException(MessageFormat.format(
JGitText.get().binaryHunkMissingNewline,