Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 78021 invoked from network); 6 Mar 2007 11:52:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Mar 2007 11:52:42 -0000 Received: (qmail 5830 invoked by uid 500); 6 Mar 2007 11:52:51 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 5731 invoked by uid 500); 6 Mar 2007 11:52:50 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 5715 invoked by uid 99); 6 Mar 2007 11:52:50 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Mar 2007 03:52:50 -0800 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Mar 2007 03:52:41 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id F19141A9838; Tue, 6 Mar 2007 03:52:20 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r515087 - /cocoon/trunk/blocks/cocoon-serializers/cocoon-serializers-impl/src/main/java/org/apache/cocoon/components/serializers/HTMLSerializer.java Date: Tue, 06 Mar 2007 11:52:20 -0000 To: cvs@cocoon.apache.org From: cziegeler@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070306115220.F19141A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: cziegeler Date: Tue Mar 6 03:52:19 2007 New Revision: 515087 URL: http://svn.apache.org/viewvc?view=rev&rev=515087 Log: Correctly handle script and style content as cdata. Modified: cocoon/trunk/blocks/cocoon-serializers/cocoon-serializers-impl/src/main/java/org/apache/cocoon/components/serializers/HTMLSerializer.java Modified: cocoon/trunk/blocks/cocoon-serializers/cocoon-serializers-impl/src/main/java/org/apache/cocoon/components/serializers/HTMLSerializer.java URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-serializers/cocoon-serializers-impl/src/main/java/org/apache/cocoon/components/serializers/HTMLSerializer.java?view=diff&rev=515087&r1=515086&r2=515087 ============================================================================== --- cocoon/trunk/blocks/cocoon-serializers/cocoon-serializers-impl/src/main/java/org/apache/cocoon/components/serializers/HTMLSerializer.java (original) +++ cocoon/trunk/blocks/cocoon-serializers/cocoon-serializers-impl/src/main/java/org/apache/cocoon/components/serializers/HTMLSerializer.java Tue Mar 6 03:52:19 2007 @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,10 +25,10 @@ /** *

A serializer converting XHTML into plain old HTML.

- * + * *

For configuration options of this serializer, please look at the * {@link XHTMLSerializer} and {@link EncodingSerializer}.

- * + * *

Any of the XHTML document type declared or used will be converted into * its HTML 4.01 counterpart, and in addition to those a "compatible" doctype * can be supported to exploit a couple of shortcuts into MSIE's rendering @@ -36,16 +36,16 @@ * *

*
"none"
- *
Not to emit any dococument type declaration.
+ *
Not to emit any dococument type declaration.
*
"compatible"
- *
The HTML 4.01 Transitional (exploiting MSIE shortcut).
+ *
The HTML 4.01 Transitional (exploiting MSIE shortcut).
*
"strict"
- *
The HTML 4.01 Strict document type.
+ *
The HTML 4.01 Strict document type.
*
"loose"
- *
The HTML 4.01 Transitional document type.
+ *
The HTML 4.01 Transitional document type.
*
"frameset"
*
The HTML 4.01 Frameset document type.
- *
+ * * * @version $Id$ */ @@ -74,6 +74,8 @@ private static final HTMLEncoder HTML_ENCODER = new HTMLEncoder(); + protected boolean encodeCharacters = true; + /** * Create a new instance of this HTMLSerializer */ @@ -194,6 +196,10 @@ length++; } + // script and style are CDATA sections by default, so no encoding + if ( "SCRIPT".equals(name) || "STYLE".equals(name) ) { + this.encodeCharacters = false; + } super.startElementImpl(XHTML1_NAMESPACE, name, name, NAMESPACES, at); } @@ -225,6 +231,22 @@ if (name.equals("META")) return; if (name.equals("PARAM")) return; + // script and style are CDATA sections by default, so no encoding + if ( "SCRIPT".equals(name) || "STYLE".equals(name) ) { + this.encodeCharacters = true; + } super.endElementImpl(XHTML1_NAMESPACE, name, name); + } + + /** + * Encode and write a specific part of an array of characters. + */ + protected void encode(char data[], int start, int length) + throws SAXException { + if ( !this.encodeCharacters ) { + this.write(data, start, length); + return; + } + super.encode(data, start, length); } }