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 9f53d448303cb5dba47fe9529ab3c46655b362f8 Author: Mark Thomas <ma...@apache.org> AuthorDate: Tue Jun 3 17:52:14 2025 +0100 Code clean-up. Formatting. No functional change. --- .../catalina/valves/ParameterLimitValve.java | 38 ++++++++++++---------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/java/org/apache/catalina/valves/ParameterLimitValve.java b/java/org/apache/catalina/valves/ParameterLimitValve.java index add411e3fd..67fb456ee0 100644 --- a/java/org/apache/catalina/valves/ParameterLimitValve.java +++ b/java/org/apache/catalina/valves/ParameterLimitValve.java @@ -40,25 +40,26 @@ import org.apache.tomcat.util.file.ConfigurationSource; /** - * This is a concrete implementation of {@link ValveBase} that enforces a limit on the number of HTTP request parameters. - * The features of this implementation include: + * This is a concrete implementation of {@link ValveBase} that enforces a limit on the number of HTTP request + * parameters. The features of this implementation include: * <ul> * <li>URL-specific parameter limits that can be defined using regular expressions</li> * <li>Configurable through Tomcat's <code>server.xml</code> or <code>context.xml</code></li> - * <li> Requires a <code>parameter_limit.config</code> file containing the URL-specific parameter limits. - * It must be placed in the Host configuration folder or in the WEB-INF folder of the web application.</li> + * <li>Requires a <code>parameter_limit.config</code> file containing the URL-specific parameter limits. It must be + * placed in the Host configuration folder or in the WEB-INF folder of the web application.</li> * </ul> * <p> - * The default limit, specified by Connector's value, applies to all requests unless a more specific - * URL pattern is matched. URL patterns and their corresponding limits can be configured via a regular expression - * mapping through the <code>urlPatternLimits</code> attribute. + * The default limit, specified by Connector's value, applies to all requests unless a more specific URL pattern is + * matched. URL patterns and their corresponding limits can be configured via a regular expression mapping through the + * <code>urlPatternLimits</code> attribute. * </p> * <p> - * The Valve checks each incoming request and enforces the appropriate limit. If a request exceeds the allowed number - * of parameters, a <code>400 Bad Request</code> response is returned. + * The Valve checks each incoming request and enforces the appropriate limit. If a request exceeds the allowed number of + * parameters, a <code>400 Bad Request</code> response is returned. * </p> * <p> * Example, configuration in <code>context.xml</code>: + * * <pre> * {@code * <Context> @@ -67,6 +68,7 @@ import org.apache.tomcat.util.file.ConfigurationSource; * } * and in <code>parameter_limit.config</code>: * </pre> + * * <pre> * {@code * /api/.*=150 @@ -86,7 +88,7 @@ public class ParameterLimitValve extends ValveBase { /** * Map for URL-specific limits */ - protected Map<Pattern, Integer> urlPatternLimits = new ConcurrentHashMap<>(); + protected Map<Pattern,Integer> urlPatternLimits = new ConcurrentHashMap<>(); /** * Relative path to the configuration file. Note: If the valve's container is a context, this will be relative to @@ -154,7 +156,7 @@ public class ParameterLimitValve extends ValveBase { } try (InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8); - BufferedReader reader = new BufferedReader(isr)) { + BufferedReader reader = new BufferedReader(isr)) { setUrlPatternLimits(reader); } catch (IOException ioe) { containerLog.error(sm.getString("parameterLimitValve.closeError"), ioe); @@ -174,10 +176,11 @@ public class ParameterLimitValve extends ValveBase { } /** - * Set the mapping of URL patterns to their corresponding parameter limits. - * The input should be provided line by line, where each line contains a pattern and a limit, separated by the last '='. + * Set the mapping of URL patterns to their corresponding parameter limits. The input should be provided line by + * line, where each line contains a pattern and a limit, separated by the last '='. * <p> * Example: + * * <pre> * /api/.*=50 * /api======/.*=150 @@ -185,7 +188,8 @@ public class ParameterLimitValve extends ValveBase { * # This is a comment * </pre> * - * @param reader A BufferedReader containing URL pattern to parameter limit mappings, with each pair on a separate line. + * @param reader A BufferedReader containing URL pattern to parameter limit mappings, with each pair on a separate + * line. */ public void setUrlPatternLimits(BufferedReader reader) { if (containerLog == null && getContainer() != null) { @@ -228,8 +232,8 @@ public class ParameterLimitValve extends ValveBase { } /** - * Checks if any of the defined patterns matches the URI of the request and if it does, - * enforces the corresponding parameter limit for the request. Then invoke the next Valve in the sequence. + * Checks if any of the defined patterns matches the URI of the request and if it does, enforces the corresponding + * parameter limit for the request. Then invoke the next Valve in the sequence. * * @param request The servlet request to be processed * @param response The servlet response to be created @@ -248,7 +252,7 @@ public class ParameterLimitValve extends ValveBase { String requestURI = context ? request.getRequestPathMB().toString() : request.getDecodedRequestURI(); // Iterate over the URL patterns and apply corresponding limits - for (Map.Entry<Pattern, Integer> entry : urlPatternLimits.entrySet()) { + for (Map.Entry<Pattern,Integer> entry : urlPatternLimits.entrySet()) { Pattern pattern = entry.getKey(); int limit = entry.getValue().intValue(); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org