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:10 UTC

[tomcat] branch main 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 main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new 527a49263e Fix NPE - Thanks to Han Li
527a49263e is described below

commit 527a49263e6ae1607bc41c739072476761cea8a4
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 eadbc56a2a..d0197797b5 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 {
 
     public 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