You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Christian Mayrhuber <cm...@iicm.edu> on 2004/03/25 20:22:56 UTC

[Bug 27802] PATCH - EncodeURLTransformer encodes off site links

On Friday 19 March 2004 21:06, you wrote:
> DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
> RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
> <http://issues.apache.org/bugzilla/show_bug.cgi?id=27802>.
> ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
> INSERTED IN THE BUG DATABASE.
>
> http://issues.apache.org/bugzilla/show_bug.cgi?id=27802
>
> EncodeURLTransformer encodes off site links
>
>            Summary: EncodeURLTransformer encodes off site links
>            Product: Cocoon 2
>            Version: Current CVS 2.1
>           Platform: Other
>         OS/Version: Other
>             Status: NEW
>           Severity: Normal
>           Priority: Other
>          Component: sitemap components
>         AssignedTo: dev@cocoon.apache.org
>         ReportedBy: christian.mayrhuber@gmx.net
>
>
> EncodeURLTransformer URL encodes all types of off-site links
> like news://foo.bla.com, http://other.host.net/foo/bla mailto:user@host.net
> ftp://foo.bla.com.
>
> I'm not sure if this is a bug in EncodeURLTransformer or in the
> encodeURL() method of the ServletContainer.
> Jetty and Tomcat behave the same in this regard.

Hi,

I've added regexp not just on element/attribute pairs, but on the attribtute 
value (the url) itself. 
This enables the EncodeURLTransformer to take care of references to
external sources. (mailto:, telnet:, ftp:, etc.)
The EncodeURLTransformer will mostly only transform relative links and will
leave the absolute ones as they are.
Document fragments refernced by <a href="#some_reference" ..> will not be 
touched per default, too.
The regexp urls patterns can be configured in the sitemap if the default is 
not suitable.
<map:transformer logger="sitemap.transformer.encodeURL" name="encodeURL" 
src="org.apache.cocoon.transformation.EncodeURLTransformer">
  <exclude-urls>http:.*|#.*|myprotocol.*</exclude-urls>
</map:transformer>

Furter, I've refactored the inner class ElementAttributeMatching to be  an 
outer class called 
org.apache.cocoon.transformation.helpers.ElementAttributeURLMatcher,
because I think it will be of use in 
org.apache.cocoon.blocks.portal.transformation.HTMLEventLinkTransformer which
has some of the problems EncodeURLTransformer has had, too.

I hope this patch doesn't introduce any new bugs.
Please review.

-- 
lg, Chris