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
commit 3b1f52fc087e1e5e36521fc81751d3bf8c45d05a Author: Mark Thomas <[email protected]> AuthorDate: Thu Mar 5 00:17:22 2026 +0000 Servlet API exposes port as int so parse it as an Integer --- java/org/apache/tomcat/util/http/parser/HttpParser.java | 15 ++++++++++++++- webapps/docs/changelog.xml | 6 ++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/java/org/apache/tomcat/util/http/parser/HttpParser.java b/java/org/apache/tomcat/util/http/parser/HttpParser.java index c829be06bd..0a7d156a5e 100644 --- a/java/org/apache/tomcat/util/http/parser/HttpParser.java +++ b/java/org/apache/tomcat/util/http/parser/HttpParser.java @@ -488,6 +488,19 @@ public class HttpParser { return result.toString(); } + /** + * @return the number if digits were found, -1 if no data was found or if data other than digits was found + */ + static long readInteger(Reader input) throws IOException { + String digits = readDigits(input); + + if (digits.isEmpty()) { + return -1; + } + + return Integer.parseInt(digits); + } + /** * @return the number if digits were found, -1 if no data was found or if data other than digits was found */ @@ -943,7 +956,7 @@ public class HttpParser { static int validatePort(Reader reader, int colonPosition) throws IOException { // Remaining characters should be numeric ... - readLong(reader); + readInteger(reader); // ... followed by EOS if (reader.read() == -1) { return colonPosition; diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 091362b537..b1e79bfa6d 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -278,6 +278,12 @@ Improve HPACK exception use, making sure <code>HpackException</code> is thrown instead of unexpected types. (remm) </fix> + <fix> + Update the parser for the HTTP <code>Host</code> header and + <code>:authority</code> pseudo header to convert the port, if any, to an + <code>Integer</code> rather than a <code>Long</code> to be consistent + with how port is exposed in the Servlet API. (markt) + </fix> </changelog> </subsection> <subsection name="Jasper"> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
