Bug 18964 - string:encodeUrl does not work with accented characters
Summary: string:encodeUrl does not work with accented characters
Status: RESOLVED WONTFIX
Alias: None
Product: Taglibs
Classification: Unclassified
Component: String Taglib (show other bugs)
Version: 1.0.1
Hardware: All other
: P3 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-04-11 17:48 UTC by Steve Morrison
Modified: 2004-11-16 19:05 UTC (History)
1 user (show)



Attachments
Test case (JSP page) (1.01 KB, text/plain)
2004-03-11 12:21 UTC, Felipe Leme
Details
Zip file with the changed files (12.89 KB, application/octet-stream)
2004-03-13 01:06 UTC, Felipe Leme
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Morrison 2003-04-11 17:48:46 UTC
 
Comment 1 Steve Morrison 2003-04-11 17:51:32 UTC
<str:encodeUrl>desayuño</str:encodeUrl> should return desayu%F1o.  Instead it
returns desayu%3Fo which is desayu?o.  All accents are converted to ?.
Comment 2 Felipe Leme 2004-03-10 05:21:39 UTC
Steve,

<str:encodeUrl> calls java.net.EncodeURL.encode(text) to encode the text.

The solution for your problem would be calling
java.net.EncodeURL.encode(text,encoding), but that method is only available on
J2SE 1.4.

We could add an attribute encoding for this tag and check the J2SE version at
runtime:


    public String changeString(String text) throws JspException {

      String result = null;
      if ( this.encoding != null ) {
        try {
          result = URLEncoder.encode( text, this.encoding );
        } catch( NoSuchMethodError exc ) {
          System.err.println( "WARNING: attribute encoding on tag encodeUrl
should be used only in  a " +
                            "J2SE 1.4 compatible web container. Using default
container.");
        } catch( UnsupportedEncodingException exc2 ) {
          System.err.println( "WARNING: unsupported encoding used on tag
encodeUrl: " + this.encoding );
        }
      }
      if ( result == null ) {
        result = URLEncoder.encode(text);
      }
      return result;
      
    }


So, Hen, what do you think about it? If you give me an ok, I will commit these
changes on CVS. Otherwise, we should mark it as WON'T FIX.

Felipe

Comment 3 Henri Yandell 2004-03-11 05:20:39 UTC
Sounds good to me. Feel free to go ahead with the change.
Comment 4 Felipe Leme 2004-03-11 12:19:46 UTC
I committed the changes on CVS, but I won't mark it as fixed yet as I couldn't
test it - my Linux setup is still messing with encoding.

I'm pretty sure the code is fine because the same code worked standalone (i.e.,
outside Tomcat). Anyway, I'll be attaching a test case.
Comment 5 Felipe Leme 2004-03-11 12:21:47 UTC
Created attachment 10756 [details]
Test case (JSP page)
Comment 6 Felipe Leme 2004-03-13 01:06:10 UTC
I rolled back the changes because it broke the build: in order to fix it, the
whole project should be compiled against J2SE 1.4, which is not a good idea.

Anyway, I'm attaching my changes as a patch.
Comment 7 Felipe Leme 2004-03-13 01:06:51 UTC
Created attachment 10772 [details]
Zip file with the changed files