You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2022/08/02 09:48:14 UTC
[tomcat] branch 9.0.x updated: Fix NPE - Thanks to Han Li
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new eba4e49b60 Fix NPE - Thanks to Han Li
eba4e49b60 is described below
commit eba4e49b605983d93cfccc636adb94f2ff25639d
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Aug 2 10:47:54 2022 +0100
Fix NPE - Thanks to Han Li
---
java/org/apache/tomcat/util/http/parser/Ranges.java | 6 +++++-
test/org/apache/tomcat/util/http/parser/TestRanges.java | 9 +++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/java/org/apache/tomcat/util/http/parser/Ranges.java b/java/org/apache/tomcat/util/http/parser/Ranges.java
index 9ded3fbfb6..c75e51e128 100644
--- a/java/org/apache/tomcat/util/http/parser/Ranges.java
+++ b/java/org/apache/tomcat/util/http/parser/Ranges.java
@@ -31,7 +31,11 @@ public class Ranges {
private Ranges(String units, List<Entry> entries) {
// Units are lower case (RFC 9110, section 14.1)
- this.units = units.toLowerCase(Locale.ENGLISH);
+ if (units == null) {
+ this.units = null;
+ } else {
+ this.units = units.toLowerCase(Locale.ENGLISH);
+ }
this.entries = Collections.unmodifiableList(entries);
}
diff --git a/test/org/apache/tomcat/util/http/parser/TestRanges.java b/test/org/apache/tomcat/util/http/parser/TestRanges.java
index 7de9dba29b..0e973e0748 100644
--- a/test/org/apache/tomcat/util/http/parser/TestRanges.java
+++ b/test/org/apache/tomcat/util/http/parser/TestRanges.java
@@ -18,6 +18,7 @@ package org.apache.tomcat.util.http.parser;
import java.io.IOException;
import java.io.StringReader;
+import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
@@ -98,6 +99,14 @@ public class TestRanges {
}
+ @Test
+ public void testNullUnits() throws Exception {
+ Ranges r = new Ranges(null, new ArrayList<>());
+ Assert.assertNotNull(r);
+ Assert.assertNull(r.getUnits());
+ }
+
+
@Test
public void testValid03() throws Exception {
Ranges r = parse("bytes=21-");
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org