Mark,

On 1/7/22 14:46, ma...@apache.org wrote:
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 fe909ba  Refactor. Add new method isToken(String) to reduce 
duplication
fe909ba is described below

commit fe909bad46150ffb9dcd436c0095ab97c20a2745
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Jan 7 19:46:15 2022 +0000

     Refactor. Add new method isToken(String) to reduce duplication
>
> [snip]
>

diff --git a/java/org/apache/tomcat/util/http/parser/HttpParser.java 
b/java/org/apache/tomcat/util/http/parser/HttpParser.java
index b06d468..7dcb631 100644
--- a/java/org/apache/tomcat/util/http/parser/HttpParser.java
+++ b/java/org/apache/tomcat/util/http/parser/HttpParser.java
@@ -237,6 +237,23 @@ public class HttpParser {
      }
+ public static boolean isToken(String s) {
+        // token = 1 * tchar (RFC 7230)
+        if (s == null) {
+            return false;
+        }
+        if (s.isEmpty()) {
+            return false;
+        }
+        for (char c : s.toCharArray()) {
+            if (!isToken(c)) {
+                return false;
+            }
+        }
+        return true;
+    }

Since this is public, maybe move the reference to the RFC up into javadoc? In this case "token" has specific meaning.

-chris

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to