myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <simon.kitch...@chello.at>
Subject Re: A Bug in org.apache.myfaces.webapp.filter.ExtensionsFilter functionallity
Date Thu, 29 Nov 2007 17:56:41 GMT
Hi Carlos,

I've done some work on the ExtensionsFilter in the past.

You may well be right that this class is the cause of your problems. It does create a fake
ResponseWriter object in order to buffer all the data generated for the page. It then performs
some post-processing of the generated page and finally writes the data out to the real ResponseWriter.
It's possible that some setting is getting lost on the way.

I'm not sure what effect something like this has:
 <%@ page contentType="text/html;charset=windows-1252"%>
but I presume it sets properties on the HttpResponse object.

See class ExtensionsResponseWrapper and ExtensionsFilter.

To actually write stuff, the ExtensionsFilter calls this method in DefaultAddResource:

    public void writeResponse(HttpServletRequest request,
                              HttpServletResponse response) throws IOException
    {
        ResponseWriter writer = new HtmlResponseWriterImpl(response.getWriter(), HtmlRendererUtils
                .selectContentType(request.getHeader("accept")),
                response.getCharacterEncoding());
        writer.write(originalResponse.toString());
    }

I can see that the final writer is created using response.getCharacterEncoding, which looks
like it is trying to follow the current setting.

Actually, I see that this bit of code to set the characterEncoding was added for this issue:
  https://issues.apache.org/jira/browse/TOMAHAWK-282
in revision 379145 (2006-02-20) so you should check that you've got a release that is newer
than that date as this might fix the problem.

You don't mention what version of Tomahawk you are using.

If using a version with this patch in it doesn't help then I guess you'll have to do some
debugging on your own. At least with open source that is possible!

Note that I don't have any time to personally try to debug this for you, but I hope this info
is some help. If you do come up with a patch I will try to review it and commit it.


Regards,

Simon

---- Carlos Adolfo Ortiz Quiros <carlos.ortiz@trebol.com.co> schrieb:
> HI you all
> 
> This is a repost, as I have not got a solution to my question by tomahawk developers
(this is regarding the Extension Filter class org.apache.myfaces.webapp.filter.ExtensionsFilter
which I consider there is a bug because the resulting page gets HTML encoded which should
not be, that is, where in the page there is a á character and using the page encoding windows-1252
 it is converted to the equivalent &#255; HTML code and thus altering the functionality
of the page as such). Following is the original POST.
> 
> Any help is appreciated.
> 
> Thank you all.
> 
>  
> 
> After a great amount of time trying to find why web page in the source code gets altered
I concluded that the Extensions Filter is doing something that should not be doing or perhaps
I don't know how to fix.
> 
>  
> 
> Here is the situation.
> 
> First code sample
> 
> <%@ page contentType="text/html;charset=windows-1252"%>
> 
> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
> 
> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
> 
> <f:view>
> 
>   <html>
> 
>     <head>
> 
>       <meta http-equiv="Content-Type"
> 
>             content="text/html; charset=windows-1252"/>
> 
>       <meta name="Eddy Johana Angarita Navarro" content="TRÉBOL Software S.A."></meta>
> 
> <script type="text/javascript" language="JavaScript">
> 
>         
> 
>         
> 
>         //Valida la longitud de un texto.
> 
> function validaLongitud(texto, longitud, e) {
> 
> if (!e) e = window.event;
> 
>  
> 
> if (!isEdicionKey(e) && texto.value.length >= longitud) {
> 
> alert("No puede digitar más de " + longitud + " caracteres.");
> 
> return false;
> 
> }
> 
>  
> 
> return true;
> 
> }
> 
> // Valida si la tecla presionada es de edición.
> 
> // Utilizar unicamente en evento "onkeydown".
> 
> function isEdicionKey(e) {
> 
> if (!e) e = window.event;
> 
> var key = e.which ? e.which : e.keyCode;
> 
>  
> 
> return (key==8 || key==9 || (key >= 33 && key <= 40) || key==45 || key==46);
> 
> }
> 
>  
> 
>         function doOnKeyDown(e) {
> 
>           var obj = document.getElementById("frmSistemas:nombreSistema");
> 
>           validaLongitud(obj.value, 10, e);
> 
>         }
> 
>         </script>              
> 
>       <title>This is a full text sample</title>
> 
>     </head>
> 
>     <body onload="alert('más o áéíóúñÑ');">This is it verbatim and m&aacute;s
to
> 
>                                            this<h:form>
> 
>         <h:inputText maxlength="10" onkeypress="return validaLongitud(this, 10, event);"/>
       
> 
>       </h:form></body>
> 
>   </html>
> 
> </f:view>
> 
>  
> 
> See the text in bold above.
> 
> I am using MyFaces tomahawk and have configured the ExtensionsFilter as stated in the
page http://myfaces.apache.org/tomahawk/extensionsFilter.html
> 
>  
> 
> I have put this page in a tomcat server and captured the generated java code and the
characters are preserved but when I look at the source code in the Internet Browser, it gets
altered to HTML characters, that is á is changed to &aacute; or &#255;.
> 
>  
> 
> See in page
> 
> <%@ page contentType="text/html;charset=windows-1252"%>
> 
> <meta http-equiv="Content-Type"
> 
>             content="text/html; charset=windows-1252"/>
> 
>  
> 
> To enforce page is interpreted correctly by browser
> 
>  
> 
> I think this is a bug because the whole page should not be encoded, only what needed
by the filter.
> 
> Is there a way to fix this or it is indeed a bug in the library.
> 
>  
> 
>  
> 
> CARLOS ADOLFO ORTIZ Q
> 
> Ingeniero de Desarrollo
> 
> TRÉBOL Software S.A.
> 
> Tel : (574)3110663 Fax : (574)3113474
> 
> Dirección Cll 16 # 28-195
> 
> Medellín - Colombia
> 
> http://www.trebol.com.co <http://www.trebol.com.co/> 
> 
>  
> 
> La información de este mensaje y sus anexos son propiedad exclusiva
> de TRÉBOL Software S.A. Es  únicamente para el uso del destinatario
> intencional  y  pueden  contener  información de carácter privado o
> confidencial. Le  informamos que cualquier revisión, retransmisión,
> divulgación,  copia  o  uso  indebido  del mismo está estrictamente
> prohibida  y será sancionada legalmente.
> 
> 
> 
> Information contained in this message and every attachment is property of TREBOL Software
S.A. Only the destiny user is able to make use of the data here contained, which is private
and/or confidential. Any revision, broadcasting, spreading, copy or illegal use of this information
is strictly prohibited and will be sanctioned by legal means.


Mime
View raw message