Skip to content

Commit 6921839

Browse files
committed
Fix \r\n handling
1 parent 3f57667 commit 6921839

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

plugins/repository-gcs/src/test/java/org/elasticsearch/repositories/gcs/GoogleCloudStorageBlobStoreRepositoryTests.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,19 @@ public void handle(final HttpExchange exchange) throws IOException {
304304
while ((read = in.read()) != -1) {
305305
boolean markAndContinue = false;
306306
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
307-
do { // search next new line char and stops
308-
char current = (char) read;
309-
if (current == '\n') {
310-
break;
311-
} else if (current != '\r') {
312-
out.write(read);
307+
do { // search next consecutive {carriage return, new line} chars and stop
308+
if ((char) read == '\r') {
309+
int next = in.read();
310+
if (next != -1) {
311+
if (next == '\n') {
312+
break;
313+
}
314+
out.write(read);
315+
out.write(next);
316+
continue;
317+
}
313318
}
319+
out.write(read);
314320
} while ((read = in.read()) != -1);
315321

316322
final String line = new String(out.toByteArray(), UTF_8);

0 commit comments

Comments
 (0)