Issue 30 in urlrewritefilter: ":" char in url results in java.io.UnsupportedEncodingException

18 views
Skip to first unread message

codesite...@google.com

unread,
Feb 17, 2009, 2:35:55 PM2/17/09
to urlre...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 30 by binarygroop: ":" char in url results in
java.io.UnsupportedEncodingException
http://code.google.com/p/urlrewritefilter/issues/detail?id=30

What steps will reproduce the problem?
1. put ":" character into url that is beeing rewriten
2. the unsupported encoding exception raise immediately


What is the expected output? What do you see instead?

I should get the page with search results

Instead I see this exception:
java.io.UnsupportedEncodingException: dog
at java.net.URLEncoder.encode(URLEncoder.java:200)
at
org.tuckey.web.filters.urlrewrite.functions.StringFunctions.escape(StringFunctions.java:49)
at
org.tuckey.web.filters.urlrewrite.utils.FunctionReplacer.functionReplace(FunctionReplacer.java:118)
at
org.tuckey.web.filters.urlrewrite.utils.FunctionReplacer.replace(FunctionReplacer.java:78)
at
org.tuckey.web.filters.urlrewrite.RuleBase.matchesBase(RuleBase.java:248)
at
org.tuckey.web.filters.urlrewrite.NormalRule.matches(NormalRule.java:91)
at
org.tuckey.web.filters.urlrewrite.RuleChain.doRuleProcessing(RuleChain.java:83)
at
org.tuckey.web.filters.urlrewrite.RuleChain.process(RuleChain.java:137)
at
org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:144)
at
org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
at
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:381)

What version of the product are you using? On what operating system?

Version 3.2.0 beta on Windows XP

Please provide any additional information below.

It seems that tuckey rewrite is unable to process character: ":". I have a
search page with for example url: http://localhost/search/town:
springfield/in/category. Having this url will result into exception beeing
thrown by tuckey and page is redirected to http://localhost/.

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

codesite...@google.com

unread,
Aug 10, 2009, 1:00:39 PM8/10/09
to urlre...@googlegroups.com

Comment #1 on issue 30 by avlesh: ":" char in url results in
java.io.UnsupportedEncodingException
http://code.google.com/p/urlrewritefilter/issues/detail?id=30

Seems invalid. An error in the rewrite rule might have led to this. Please
post such
problems on the mailing list first.

codesite...@google.com

unread,
Aug 10, 2009, 5:05:18 PM8/10/09
to urlre...@googlegroups.com
Updates:
Status: Invalid

Comment #2 on issue 30 by tuckey: ":" char in url results in
java.io.UnsupportedEncodingException
http://code.google.com/p/urlrewritefilter/issues/detail?id=30

Agree, please post exact rule used and debug log so that this can be
investigated
further.

codesite...@google.com

unread,
Sep 30, 2009, 7:53:33 AM9/30/09
to urlre...@googlegroups.com

Comment #3 on issue 30 by fo...@ilmtigers.de: ":" char in url results in
java.io.UnsupportedEncodingException
http://code.google.com/p/urlrewritefilter/issues/detail?id=30

I can confirm this issue. The error occurs, when a parameter contains a
colon. At our
site, for example, we have the following rule for rewriting search queries:

<rule>
<name>redirect /search/SEARCH</name>
<condition type="parameter" name="search">(.+)</condition>
<from>^/+search$</from>
<to type="redirect" last="true">/search/${escape:%1}</to>
</rule>

The following query results in a UnsupportedEncodingException as described
above:

http://<ourhost>/search?search=test:

The reason for this exception is found in StringFunctions.java. If a
parameter
contains a colon (':'), the prefix is treaded as an encoding name:

String encoding = "UTF-8";
if ( FIND_COLON_PATTERN.matcher(subject).find()) {
encoding = subject.substring(0, subject.indexOf(':'));
subject = subject.substring(subject.indexOf(':')+1);
}

I didn't find this feature's documentation and I strongly suggest to
disable it - or
at least make it optional.

codesite...@google.com

unread,
Oct 2, 2009, 4:30:57 AM10/2/09
to urlre...@googlegroups.com

Comment #4 on issue 30 by rjoberon: ":" char in url results in
java.io.UnsupportedEncodingException
http://code.google.com/p/urlrewritefilter/issues/detail?id=30

I would suggest to set this bug to "open", since this issue is not solved!
It really
breaks functionality: parameter values containing a colon (":") are not
supported.

codesite...@google.com

unread,
Oct 2, 2009, 7:37:28 AM10/2/09
to urlre...@googlegroups.com

Comment #5 on issue 30 by kromagg: ":" char in url results in
java.io.UnsupportedEncodingException
http://code.google.com/p/urlrewritefilter/issues/detail?id=30

Does this trigger when you encode the colon? (unencoded colons are not
legal in
parameter names/values)

codesite...@google.com

unread,
Oct 8, 2009, 10:23:56 AM10/8/09
to urlre...@googlegroups.com

Comment #6 on issue 30 by fo...@ilmtigers.de: ":" char in url results in
java.io.UnsupportedEncodingException
http://code.google.com/p/urlrewritefilter/issues/detail?id=30

Please excuse the inaccurate description above - we are encoding the
parameters, that is:

http://<ourhost>/search?search=test%3Atest

produces the error above

urlrewri...@googlecode.com

unread,
Jan 19, 2010, 7:49:16 AM1/19/10
to urlre...@googlegroups.com

Comment #7 on issue 30 by gromgull: ":" char in url results in
java.io.UnsupportedEncodingException
http://code.google.com/p/urlrewritefilter/issues/detail?id=30

+1 for reopening. This really seems like a bug - and not a config issue.

urlrewri...@googlecode.com

unread,
Jan 19, 2010, 11:27:37 AM1/19/10
to urlre...@googlegroups.com
Updates:
Owner: avlesh

Comment #8 on issue 30 by avlesh: ":" char in url results in
java.io.UnsupportedEncodingException
http://code.google.com/p/urlrewritefilter/issues/detail?id=30

Re-opening the ticket.

urlrewri...@googlecode.com

unread,
Jan 19, 2010, 11:31:42 AM1/19/10
to urlre...@googlegroups.com

Comment #9 on issue 30 by kromagg: ":" char in url results in
java.io.UnsupportedEncodingException
http://code.google.com/p/urlrewritefilter/issues/detail?id=30

Indeed, when you use ${escape:...} the colon is used as an indicator for
encoding.
This syntax supports escaping the colon with a simple '\', but as you can't
seem to
nest functions properly, there seems to be no way to actually make use of
that.

So no real work-around yet except don't use $escape{} and a colon together.
I tend to
agree with the commenters. Would it be acceptable if I submitted a patch
which falls
back to UTF-8 on an UnsupportedEncodingException? I've got it working but
need to do
some more testing. I'll attach it.

Attachments:
encoding_exception.patch 2.7 KB

urlrewri...@googlecode.com

unread,
Jan 19, 2010, 11:35:56 AM1/19/10
to urlre...@googlegroups.com

Comment #10 on issue 30 by avlesh: ":" char in url results in
java.io.UnsupportedEncodingException
http://code.google.com/p/urlrewritefilter/issues/detail?id=30

Thanks kronmagg for the patch. And it was quick too! Falling back on UTF-8
is not a
bad idea. Can you please add/modify test cases to in a revised patch?

urlrewri...@googlecode.com

unread,
Jan 20, 2010, 3:39:10 AM1/20/10
to urlre...@googlegroups.com

Comment #11 on issue 30 by kromagg: ":" char in url results in
java.io.UnsupportedEncodingException
http://code.google.com/p/urlrewritefilter/issues/detail?id=30

I added some tests to FunctionReplacerTest. Note that there was a bug in my
patch. It
seems ${escape} expected a String of the forum "UTF-16:blah" while
${unescape}
expected one of the forum "blah:UTF-16". Not sure why...

Attachments:
enc_patch.txt 4.5 KB

urlrewri...@googlecode.com

unread,
Jan 20, 2010, 3:43:13 AM1/20/10
to urlre...@googlegroups.com

Comment #12 on issue 30 by kromagg: ":" char in url results in
java.io.UnsupportedEncodingException
http://code.google.com/p/urlrewritefilter/issues/detail?id=30

Too soon on the "save changes" button. I changed unescape so they now both
use
"UTF-16:blah" by convention. I'm not entirely convinced anyone actually has
a use for
this feature in either case. AFAICT the only valid encoding you'd ever want
to use in
this scenario is UTF-8.

urlrewri...@googlecode.com

unread,
Feb 13, 2010, 3:44:56 PM2/13/10
to urlre...@googlegroups.com
Updates:
Status: Accepted

Comment #13 on issue 30 by avlesh: ":" char in url results in
java.io.UnsupportedEncodingException
http://code.google.com/p/urlrewritefilter/issues/detail?id=30

Changed the status from "invalid". Will shortly review "kromagg's" patch ...

urlrewri...@googlecode.com

unread,
Feb 13, 2010, 3:53:00 PM2/13/10
to urlre...@googlegroups.com

Comment #14 on issue 30 by avlesh: ":" char in url results in
java.io.UnsupportedEncodingException
http://code.google.com/p/urlrewritefilter/issues/detail?id=30

Issue 63 has been merged into this issue.

urlrewri...@googlecode.com

unread,
Jul 28, 2010, 9:23:59 PM7/28/10
to urlre...@googlegroups.com
Updates:
Status: Fixed

Comment #15 on issue 30 by tuckey: ":" char in url results in
java.io.UnsupportedEncodingException
http://code.google.com/p/urlrewritefilter/issues/detail?id=30

Thanks. Have applied a slightly modified patch
http://code.google.com/p/urlrewritefilter/source/detail?r=293

This will be in the version 4 release.


Reply all
Reply to author
Forward
0 new messages