struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Evans (JIRA)" <j...@apache.org>
Subject [jira] Reopened: (STR-1850) ResponseFilter does not handle UTF-8 encoded characters with &#
Date Mon, 24 Apr 2006 22:47:10 GMT
     [ http://issues.apache.org/struts/browse/STR-1850?page=all ]
     
David Evans reopened STR-1850:
------------------------------

    Assign To: David Evans  (was: Struts Developer Mailing List)

> ResponseFilter does not handle UTF-8 encoded characters with &#
> ---------------------------------------------------------------
>
>          Key: STR-1850
>          URL: http://issues.apache.org/struts/browse/STR-1850
>      Project: Struts Action 1
>         Type: Bug

>   Components: Action
>     Versions: 1.1 Final
>  Environment: Operating System: All
> Platform: All
>     Reporter: Dave Hodson
>     Assignee: David Evans

>
> If I have a UTF-8 encoded character like "&#22530;" (堂, a building in
> Traditional Chinese) and use this value in an html tag (e.g. html:text), the '&'
> is encoded to "&amp;", which produces output that looks like "&amp;#22530;" 
> The filter method should "look ahead" when it goes into the '&' case and if the
> following char is '#', it should not modify the '&' char. 
> The filter method from ResponseUtils with a suggested change:
>         for (int i = 0; i < content.length; i++) {
>             switch (content[i]) {
>             case '<':
>                 result.append("&lt;");
>                 break;
>             case '>':
>                 result.append("&gt;");
>                 break;
>             case '&':
> --->	        if (content[i + 1] != '#')
> --->		  result.append("&amp;");
> --->		else
>                   result.append("&");
>                 break;
>             case '"':
>                 result.append("&quot;");
>                 break;
>             case '\'':
>                 result.append("&#39;");
>                 break;
>             default:
>                 result.append(content[i]);
>             }
>         }
> This probably needs a minor adjustment, as this doesn't handle the case where
> the '&' char is the last character in the String (bounds check)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/struts/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


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


Mime
View raw message