[
https://issues.apache.org/jira/browse/COCOON-1943?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Alexander Klimetschek reopened COCOON-1943:
-------------------------------------------
The fix for this was not enough. The code failed when the URI contains special
characters that have to be encoded in URIs. Since the code parses and splits
the different parts of the URI and then reassembles it, it must handle
encoding/decoding of all parts correctly - which does not work easily with the
java.net.URI class which is not built for that scenario. I had patched that
locally (in blocks-fw) and now applied it to servlet-services
(ServletConnection).
See the comment from my patch below for details:
<snip_details>
Manually build the URI because decoding and then recoding the query
does not work on the query-string-level: it needs to be done after
each parameter pair (eg. 'a=b') has been extracted and split into key
and value. Then both parts have to be decoded (they might not only
contain umlaute but also the delimiters '=' and '&'). But this is not
possible when using the java.net.URI() constructors with multiple
parameters for each part (eg. scheme, path, query) because the query
will always be encoded as entire string. If you pass something that
is already encoded, eg. has lots of %xy inside, it will mess up those
existing encodings. Thus you can only use the URI(String) constructor
for parsing *existing*, thus already encoded, URIs or build the URI
by hand like below.
</snip_details>
> [Patch] Parameters in blocks-protocol URIs get decoded too early
> ----------------------------------------------------------------
>
> Key: COCOON-1943
> URL: https://issues.apache.org/jira/browse/COCOON-1943
> Project: Cocoon
> Issue Type: Bug
> Components: - Servlet service framework
> Affects Versions: 2.2-dev (Current SVN)
> Reporter: Alexander Klimetschek
> Attachments: cocoon-blocks-fw-raw-encoded-URIs.patch
>
>
> When you pass parameters in the query part of a block-protocol URI, eg.
> "block:super:/dosomething?param1=alpha¶m2=beta", and they include some
> encoded stuff, eg. "<br/>" encoded as "%3Cbr/%3E", this will get decoded
> before the actual servlet request happens. This takes place in
> BlockConnection.parseBlockURI() when uri.getSchemeSpecificPart() is called,
> which will decode the string. Instead, one should call
> uri.getRawSchemeSpecificPart(), which is exactly what the patch does.
> (A little bit Off-topic): The general point here is that I am calling a form
> that is handled in the super block. Since you cannot pass on request
> parameters from a POST call (that comes from the browser) to the other
> (super) block called via the blocks-protocol (because the only interface you
> have is the Source, where you can only pass information via the URI), you
> have to put all parameters in the uri. I have written a simple input module
> that creates a "param1=alpha¶m2=beta" string from another input module
> (preferrably request-param) so that you simply call:
> "block:super:/dosomething?{params-to-uri:request-param}". This might be
> integrated into Cocoon as a standard InputModule.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.