You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by "David Evans (JIRA)" <ji...@apache.org> on 2006/04/25 00:49:09 UTC

[jira] Closed: (STR-1850) ResponseFilter does not handle UTF-8 encoded characters with &#

     [ http://issues.apache.org/struts/browse/STR-1850?page=all ]
     
David Evans closed STR-1850:
----------------------------

    Resolution: Fixed

> 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