This is an automated email from the ASF dual-hosted git repository. ramyav pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/olingo-odata4.git
The following commit(s) were added to refs/heads/master by this push: new 8bd229b [OLINGO-1499]Fix case-sensitive handling of Content-Type header in BatchLineReader 8bd229b is described below commit 8bd229b40e30710525a056a4c395caf2565fe353 Author: ramya vasanth <ramya.vasa...@sap.com> AuthorDate: Fri Jan 22 12:44:01 2021 +0530 [OLINGO-1499]Fix case-sensitive handling of Content-Type header in BatchLineReader --- .../server/core/deserializer/batch/BatchLineReader.java | 3 ++- .../core/deserializer/batch/BatchLineReaderTest.java | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchLineReader.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchLineReader.java index a27e311..be1b0e6 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchLineReader.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/deserializer/batch/BatchLineReader.java @@ -24,6 +24,7 @@ import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import org.apache.olingo.commons.api.format.ContentType; import org.apache.olingo.commons.api.http.HttpHeader; @@ -95,7 +96,7 @@ public class BatchLineReader { private void updateCurrentCharset(final String currentLine) { if (currentLine != null) { - if (currentLine.startsWith(HttpHeader.CONTENT_TYPE)) { + if (currentLine.toLowerCase(Locale.ENGLISH).startsWith(HttpHeader.CONTENT_TYPE.toLowerCase(Locale.ENGLISH))) { int cutOff = currentLine.endsWith(CRLF) ? 2 : currentLine.endsWith(LFS) ? 1 : 0; final ContentType contentType = ContentType.parse( currentLine.substring(HttpHeader.CONTENT_TYPE.length() + 1, currentLine.length() - cutOff).trim()); diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/BatchLineReaderTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/BatchLineReaderTest.java index 7c8c01c..4ec44a6 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/BatchLineReaderTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/deserializer/batch/BatchLineReaderTest.java @@ -271,6 +271,21 @@ public class BatchLineReaderTest { } @Test + public void specialCharactersInJsonWithLowercaseContentType() throws Exception { + final String text = "\n" + + "content-type: application/json\n" + + "\n" + + "{\"text\": \"ä€ß\"}\n"; + BatchLineReader reader = create(text); + reader.readLine(); + reader.readLine(); + reader.readLine(); + assertEquals("{\"text\": \"ä€ß\"}\n", reader.readLine()); + assertNull(reader.readLine()); + reader.close(); + } + + @Test public void rawBytes() throws Exception { byte[] content = new byte[Byte.MAX_VALUE - Byte.MIN_VALUE + 1]; // binary content, not a valid UTF-8 representation of a string