You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2003/11/21 23:21:34 UTC

DO NOT REPLY [Bug 24908] New: - ResponseFilter does not handle UTF-8 encoded characters with &#

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24908>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24908

ResponseFilter does not handle UTF-8 encoded characters with &#

           Summary: ResponseFilter does not handle UTF-8 encoded characters
                    with &#
           Product: Struts
           Version: 1.1 Final
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Utilities
        AssignedTo: struts-dev@jakarta.apache.org
        ReportedBy: davehod@speakeasy.net


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)

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