Return-Path: Delivered-To: apmail-shale-issues-archive@locus.apache.org Received: (qmail 73758 invoked from network); 9 Jun 2008 14:46:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Jun 2008 14:46:29 -0000 Received: (qmail 13714 invoked by uid 500); 9 Jun 2008 14:46:31 -0000 Delivered-To: apmail-shale-issues-archive@shale.apache.org Received: (qmail 13690 invoked by uid 500); 9 Jun 2008 14:46:31 -0000 Mailing-List: contact issues-help@shale.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@shale.apache.org Delivered-To: mailing list issues@shale.apache.org Received: (qmail 13679 invoked by uid 99); 9 Jun 2008 14:46:31 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Jun 2008 07:46:31 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Jun 2008 14:45:43 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 53975234C136 for ; Mon, 9 Jun 2008 07:46:05 -0700 (PDT) Message-ID: <1444707640.1213022765337.JavaMail.jira@brutus> Date: Mon, 9 Jun 2008 07:46:05 -0700 (PDT) From: "Sorina Grave (JIRA)" To: issues@shale.apache.org Subject: [jira] Commented: (SHALE-488) Script contents should be enclosed in CDATA section for XML documents In-Reply-To: <345509442.1208680685276.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/struts/browse/SHALE-488?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44089#action_44089 ] Sorina Grave commented on SHALE-488: ------------------------------------ I agree that the output of JavaScript to the HtmlWriter should be enclosed within a CDATA section for XHTML because the validation for XHTML 1.0 Transitional fails when JavaScript contains charactes such as "<" or"--". The problem is actually down to the detection of XHTMLContentType in HtmlRenderUtils - the list of current content types is checked against the following supported list: String[] supportedContentTypeArray = new String[]{HTML_CONTENT_TYPE, ANY_CONTENT_TYPE,XHTML_CONTENT_TYPE, APPLICATION_XML_CONTENT_TYPE, TEXT_XML_CONTENT_TYPE}; Since the first check and the first element in the list are HTML, the value of _contentType will be always be set to HTML_CONTENT_TYPE (See selectContentType from HtmlRenderUtils.java). Another problem is that "isAllowedCdataSection" method is also called together with isXHTMLContentType: I have tried adding to web.xml the the entry corresponding to ALLOW_CDATA_SECTION_ON ("org.apache.myfaces.ResponseWriter.CdataSectionOn") but it didn't make any difference. Any ideas on how this setting should be used? this section: if(isScriptOrStyle()) { if(HtmlRendererUtils.isXHTMLContentType(_contentType)) { if(HtmlRendererUtils.isAllowedCdataSection(FacesContext.getCurrentInstance())) { _writer.write(CDATA_START); } } else { _writer.write(COMMENT_START); } } should be replaced by something like this (The decision to write either CDATA section or HTML comment should be made based on Doctype declared at the top of the page) if(isScriptOrStyle()) { if(HtmlRendererUtils.isXHTMLDocType(pageContext)) { _writer.write(CDATA_START); } else { _writer.write(COMMENT_START); } } I can actually see the value of writer's buffer (after it has appended PageContext) and in my case, this contains: The document type should be determined by parsing the buffer and it should be used used to decide whether to write CDATA_START or COMMENT_START. > Script contents should be enclosed in CDATA section for XML documents > --------------------------------------------------------------------- > > Key: SHALE-488 > URL: https://issues.apache.org/struts/browse/SHALE-488 > Project: Shale > Issue Type: Improvement > Components: Validator > Affects Versions: 1.0.4 > Environment: XML content types, including XHTML > Reporter: Jeff Tsay > > When the validator script gets rendered, it outputs raw Javascript inside the