This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 7.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/7.0.x by this push: new 5c31b92 Refactor Hostname validation to improve performance. 5c31b92 is described below commit 5c31b92d73d426d9deaa47da55ed7b43b6d782b3 Author: Mark Thomas <ma...@apache.org> AuthorDate: Tue Apr 30 12:17:23 2019 +0100 Refactor Hostname validation to improve performance. Patch provided by Uwe Hees. --- java/org/apache/tomcat/util/http/parser/HttpParser.java | 16 ++++++++-------- .../tomcat/util/http/parser/TesterHostPerformance.java | 1 + webapps/docs/changelog.xml | 8 ++++++++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/java/org/apache/tomcat/util/http/parser/HttpParser.java b/java/org/apache/tomcat/util/http/parser/HttpParser.java index bdf12e4..4cff050 100644 --- a/java/org/apache/tomcat/util/http/parser/HttpParser.java +++ b/java/org/apache/tomcat/util/http/parser/HttpParser.java @@ -1012,7 +1012,14 @@ public class HttpParser { } public DomainParseState next(int c) { - if (HttpParser.isAlpha(c)) { + if (c == -1) { + if (allowsEnd) { + return END; + } else { + throw new IllegalArgumentException( + sm.getString("http.invalidSegmentEndState", this.name())); + } + } else if (HttpParser.isAlpha(c)) { return ALPHA; } else if (HttpParser.isNumeric(c)) { return NUMERIC; @@ -1030,13 +1037,6 @@ public class HttpParser { throw new IllegalArgumentException(sm.getString("http.invalidCharacterDomain", Character.toString((char) c), errorLocation)); } - } else if (c == -1) { - if (allowsEnd) { - return END; - } else { - throw new IllegalArgumentException( - sm.getString("http.invalidSegmentEndState", this.name())); - } } else if (c == '-') { if (allowsHyphen) { return HYPHEN; diff --git a/test/org/apache/tomcat/util/http/parser/TesterHostPerformance.java b/test/org/apache/tomcat/util/http/parser/TesterHostPerformance.java index 7d2d2ff..8f5080d 100644 --- a/test/org/apache/tomcat/util/http/parser/TesterHostPerformance.java +++ b/test/org/apache/tomcat/util/http/parser/TesterHostPerformance.java @@ -36,6 +36,7 @@ public class TesterHostPerformance { List<Object[]> result = new ArrayList<Object[]>(); result.add(new Object[] { "localhost" }); result.add(new Object[] { "tomcat.apache.org" }); + result.add(new Object[] { "tomcat.apache.org." }); result.add(new Object[] { "127.0.0.1" }); result.add(new Object[] { "255.255.255.255" }); result.add(new Object[] { "[::1]" }); diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index ed52e35..433d2fd 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -96,6 +96,14 @@ </fix> </changelog> </subsection> + <subsection name="Coyote"> + <changelog> + <scode> + Refactor Hostname validation to improve performance. Patch provided by + Uwe Hees. (markt) + </scode> + </changelog> + </subsection> <subsection name="Other"> <changelog> <add> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org