myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leonardo Uribe (JIRA)" <...@myfaces.apache.org>
Subject [jira] Resolved: (MYFACES-2801) HtmlResponseWriterImpl needs to deal with <script> and <style> tags properly on both html and xhtml
Date Sat, 10 Jul 2010 22:19:55 GMT

     [ https://issues.apache.org/jira/browse/MYFACES-2801?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Leonardo Uribe resolved MYFACES-2801.
-------------------------------------

    Fix Version/s: 2.0.1-SNAPSHOT
       Resolution: Fixed

Added a param called org.apache.myfaces.WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG by default
true to control when to append <!-- and //--> on script content when text/html content
type is used.

> HtmlResponseWriterImpl needs to deal with <script> and <style> tags properly
on both html and xhtml 
> ----------------------------------------------------------------------------------------------------
>
>                 Key: MYFACES-2801
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2801
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-314
>    Affects Versions: 2.0.0
>            Reporter: Leonardo Uribe
>            Assignee: Leonardo Uribe
>             Fix For: 2.0.1-SNAPSHOT
>
>
> I started to solve this issue on MYFACES-2779, but definitively it deserves to have a
separate issue.
> HtmlResponseWriterImpl needs to deal with <script> and <style> tags properly
on both html and xhtml. There is a very old issue (MYFACES-1353) that suggest a review now
donated trinidad code for xhtml.
> After checking the ResponseWriter implementations of trinidad, and do some test on ri
about, the following points should be taken into account before solve this issue:
> - When jsp is used, part of the page is rendered by it and the other part are renderer
by jsf using the ResponseWriter implementation. That means if there is a <script> on
a page, no xml comment wraps the content. But the things are different in facelets, because
the jsf ResponseWriter implementation is used to render everything. So, if facelets founds
a <script> or <style>, it call ResponseWriter.startElement and ResponseWriter.endElement
and all related methods.
> - When facelets is used, we first parse .xhtml files with a SAX parser. That means invalid
xml markup makes facelets fail. For example:
> <script type="text/javascript">
>   alert("<EM>This won't work<\/EM>");
> </script>
>   Since <script> and <style> content is PCDATA on the dtd, the SAX parser
does not make distinction and parse the code inside <script> as if the content was more
xhtml.
> - The following notation is valid for text/html responses:
> <style type="text/css">
> .x23 { background:red; }
> </style>
> <style type="text/css">
> <![CDATA[
> .x24 { background:red; }
> ]]>
> </style>
> <style type="text/css">
> /* <![CDATA[ */
> .x25 { background:red; }
> /* ]]> */
> </style>
> <script type="text/javascript">
> /* <![CDATA[ */
>   alert("<EM>This work 1</EM>");
> /* ]]> */
> </script>
> <script type="text/javascript">
> //<![CDATA[
>   alert("<EM>This work 2</EM>");
> //]]>
> </script>
> <script type="text/javascript">
> <!--
>   alert("<EM>This work 3</EM>");
> //-->
> </script>
> <script type="text/javascript">
>   alert("This work 4");
> </script>
>  - This syntax is not valid in xhtml:
> <script type="text/javascript">
> <!--
>   alert("<EM>This won't work in xhtml</EM>");
> //-->
> </script>
>    In this case, using //<![CDATA[ or /*<![CDATA[*/ is preferred
>  - This syntax pass the SAX parser but fails later if text/html content type is used
and IE.
> <script type="text/javascript">
> <![CDATA[
>   /* Only valid if it is used Xhtml as XML */
>   alert("<EM>This work on firefox</EM>");
> ]]>
> </script>
> - "<!--" and "//-->" could be added as wrapper for <script> content when
text/html is used.
> - "//<![CDATA[" and "//]]>" must be added as a wrapper for <script> and <style>
(without "//") content and xhtml is used. The reason is in html, <script> and <style>
content are considered cdata, but in xhtml it is pcdata by the dtd, but in fact, the intention
is, content inside these tags should not be parsed by the web client. Mojarra append this
blocks automatically, and I think it is fine to do this too.
> - The set used to prevent include content inside tags that should be empty should only
be used in text/html reponses. In xhtml this is not required.
> - Trinidad HtmlResponseWriter has a fast solution to check for empty html elements. We
should include it on myfaces.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message