cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 14541] New: - NPE: in HttpRequest.decode() when setCharacterEncoding() is used.
Date Thu, 14 Nov 2002 09:40:58 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14541>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14541

NPE: in HttpRequest.decode() when setCharacterEncoding() is used.

           Summary: NPE: in HttpRequest.decode() when setCharacterEncoding()
                    is used.
           Product: Cocoon 2
           Version: 2.0.3
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: core
        AssignedTo: cocoon-dev@xml.apache.org
        ReportedBy: kenneth@ihavemoved.com


If you changed the form-encoding in a 
corg.apache.cocoon.environment.http.HttpRequest, then if you call getParameter
(String) or getParameterValues(String) on the same request object, looking for 
a parameter which is not supplied, a NullPointerException is thrown in the 
decode() method.

To Reproduce, create a trivial pipeline such as the following:
(in this example "request-parameter" refers to a 
org.apache.cocoon.matching.RequestParameterMatcher, and "set-encoding" is a 
org.apache.cocoon.acting.SetCharacterEncodingAction.)

  <map:match pattern="foo">
    <map:act type="set-encoding">
      <map:parameter name="form-encoding" value="UTF-8"/>
    </map:act>
    <map:match type="request-parameter" pattern="EMPTY_PARAM">
      <!-- any generator and serializer can be here -->
    </map:match>
  </map:match>

Accessing the url "/foo?EMPTY_PARAM=bar" works successfully.

However, accessing the url: "/foo"
This will throw a NPE, even though this pipeline should not continue to execute 
past the second matcher.

I am pretty sure this bug can be fixed with a simple null check in the decode() 
method of HttpRequest (line 300), i.e.

if (str == null) return null;
else { str.getBytes(); ... }

*WORKAROUND* This bug can be avoided by writing a custom action which calls 
request.setCharacterEncoding(null) before an optional parameter is attempted to 
be retrieved from the sitemap.

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message