2011/11/7 Rainer Jung <rainer.j...@kippdata.de>:
> Hi Konstantin,
>
> On 07.11.2011 02:46, kkoli...@apache.org wrote:
>> Author: kkolinko
>> Date: Mon Nov  7 10:46:14 2011
>> New Revision: 1198696
>>
>> URL: http://svn.apache.org/viewvc?rev=1198696&view=rev
>> Log:
>> Introduce new request attribute to be used to mark request if there was a 
>> failure during parameter parsing,
>> and a Filter that triggers parameter parsing and rejects requests marked 
>> with that attribute.
>>
>> Added:
>>     tomcat/trunk/java/org/apache/catalina/filters/FailedRequestFilter.java   
>> (with props)
>> Modified:
>>     tomcat/trunk/java/org/apache/catalina/Globals.java
>>     tomcat/trunk/java/org/apache/catalina/connector/Request.java
>>     tomcat/trunk/java/org/apache/tomcat/util/http/Parameters.java
>>
>>
>>      /**
>> +     * The request attribute that is set to {@code Boolean.TRUE} if some 
>> request
>> +     * parameters have been ignored during request parameters parsing. It 
>> can
>> +     * happen, for example, if there is a limit on the total count of 
>> parseable
>> +     * parameters, or if parameter cannot be decoded, or any other error
>> +     * happened during parameter parsing.
>> +     */
>> +    public static final String PARAMETER_PARSE_FAILED_ATTR =
>> +        "org.apache.catalina.parameter_parse_failed";
>
> I don't now if we ever have to make the new request attribute available
> in coyote request, but in o.a.c.connector.Request there is code that
> only passes attributes down to the coyote request if the attribute name
> starts with "org.apache.tomcat". See removeAttribute() and setAttribute():
>
> 1413         // Pass special attributes to the native layer
> 1414         if (name.startsWith("org.apache.tomcat.")) {
> 1415             coyoteRequest.getAttributes().remove(name);
> 1416         }
> ...
> 1520         // Pass special attributes to the native layer
> 1521         if (name.startsWith("org.apache.tomcat.")) {
> 1522             coyoteRequest.setAttribute(name, value);
> 1523         }
>
> In fact this use of "org.apache.tomcat." could also another Global constant.
>

Thank you for the comment.

I agree "org.apache.tomcat." could be a constant.
Need to think of a good name like COYOTE_ATTR_PREFIX.
The "Pass ... to the native layer" comment is understandable,
but seems outdated with Nio implementation there besides Apr one.

If there isn't a constant, there could be a comment in Globals
mentioning the prefix.


Regarding PARAMETER_PARSE_FAILED_ATTR, its value is present
in the "native layer" as Parameters.isParseFailed(),
and the attribute is used only to pass this information up to Servlets.

I delegate the decision what to do to Valves/Filters/Servlets that
check the attribute. I do not see anything that can happen at the
"native layer".


Instead of Request#checkParameterParseFailed() there could be
alternative implementation as a new "if(name.equals(...))" branch in
Request#getAttribute().

Side effects are that the new attribute is listed in
Request.getAttributeNames() enumeration (unlike other special
attributes that are omitted there) and can be changed by
Request#setAttribute(), Request#removeAttribute().


Best regards,
Konstantin Kolinko

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

Reply via email to