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 f16e7e781e Servlet API exposes port as int so parse it as an Integer
f16e7e781e is described below
commit f16e7e781e946611cc03bd5c30c8f918035a1857
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 710cf9a824..196d4df4eb 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 9985f934c7..8b28a45f2b 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -175,6 +175,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]