cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject svn commit: r654403 - in /cocoon/trunk/blocks/cocoon-html/cocoon-html-impl/src: changes/changes.xml main/java/org/apache/cocoon/transformation/NekoHTMLTransformer.java
Date Thu, 08 May 2008 03:44:59 GMT
Author: joerg
Date: Wed May  7 20:44:59 2008
New Revision: 654403

URL: http://svn.apache.org/viewvc?rev=654403&view=rev
Log:
COCOON-2063: Fix encoding issue in NekoHTMLTransformer (http://marc.info/?l=xml-cocoon-dev&m=120905050708311&w=4)

Modified:
    cocoon/trunk/blocks/cocoon-html/cocoon-html-impl/src/changes/changes.xml
    cocoon/trunk/blocks/cocoon-html/cocoon-html-impl/src/main/java/org/apache/cocoon/transformation/NekoHTMLTransformer.java

Modified: cocoon/trunk/blocks/cocoon-html/cocoon-html-impl/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-html/cocoon-html-impl/src/changes/changes.xml?rev=654403&r1=654402&r2=654403&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-html/cocoon-html-impl/src/changes/changes.xml (original)
+++ cocoon/trunk/blocks/cocoon-html/cocoon-html-impl/src/changes/changes.xml Wed May  7 20:44:59
2008
@@ -24,8 +24,12 @@
     +-->
 <document>
   <body>
-    <release version="1.0.0-RC1" date="2007-??-??" description="unreleased">  
-      
+    <release version="1.0.1" date="TBD" description="unreleased">
+      <action dev="vgritsenko" type="fix" fixes-bug="COCOON-2063">
+        Fix encoding issue in NekoHTMLTransformer.
+      </action>
+    </release>     
+    <release version="1.0.0" date="2008-03-25" description="released">
     </release>     
     <release version="1.0.0-M1" date="2007-03-02" description="released">    
       <action dev="crossley" type="add" fixes-bug="COCOON-1206" due-to="Miles Elam" due-to-email="miles@geekspeak.org">

Modified: cocoon/trunk/blocks/cocoon-html/cocoon-html-impl/src/main/java/org/apache/cocoon/transformation/NekoHTMLTransformer.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-html/cocoon-html-impl/src/main/java/org/apache/cocoon/transformation/NekoHTMLTransformer.java?rev=654403&r1=654402&r2=654403&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-html/cocoon-html-impl/src/main/java/org/apache/cocoon/transformation/NekoHTMLTransformer.java
(original)
+++ cocoon/trunk/blocks/cocoon-html/cocoon-html-impl/src/main/java/org/apache/cocoon/transformation/NekoHTMLTransformer.java
Wed May  7 20:44:59 2008
@@ -16,8 +16,9 @@
  */
 package org.apache.cocoon.transformation;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
@@ -30,8 +31,8 @@
 import org.apache.cocoon.ProcessingException;
 import org.apache.cocoon.components.NekoHtmlSaxParser;
 import org.apache.cocoon.environment.SourceResolver;
-import org.apache.cocoon.xml.dom.DOMBuilder;
 import org.apache.cocoon.xml.IncludeXMLConsumer;
+import org.apache.cocoon.xml.dom.DOMBuilder;
 import org.apache.excalibur.source.Source;
 import org.w3c.dom.Document;
 import org.xml.sax.Attributes;
@@ -96,7 +97,7 @@
                              Attributes attr)
     throws SAXException {
         super.startElement(uri, name, raw, attr);
-		if (this.tags.containsKey(name)) {
+        if (this.tags.containsKey(name)) {
             this.startTextRecording();
         }
     }
@@ -144,15 +145,13 @@
      * @param text the string to be tidied
      */
     private void normalize(String text) throws ProcessingException {
+        Reader reader = new StringReader(text);
         try {
             NekoHtmlSaxParser parser = new NekoHtmlSaxParser(this.properties);
 
-            ByteArrayInputStream bais =
-                new ByteArrayInputStream(text.getBytes());
-
             DOMBuilder builder = new DOMBuilder();
             parser.setContentHandler(builder);
-            parser.parse(new InputSource(bais));
+            parser.parse(new InputSource(reader));
             Document doc = builder.getDocument();
 
             IncludeXMLConsumer.includeNode(doc, this.contentHandler, this.lexicalHandler);
@@ -160,13 +159,18 @@
             throw new ProcessingException(
                 "Exception in NekoHTMLTransformer.normalize()",
                 e);
+        } finally {
+            try {
+                reader.close();
+            } catch (IOException e) {
+                throw new ProcessingException(e);
+            }
         }
     }
 
     /**
      * Setup this component, passing the tag names to be tidied.
      */
-
     public void setup(SourceResolver resolver,
                       Map objectModel,
                       String src,
@@ -175,7 +179,7 @@
         super.setup(resolver, objectModel, src, par);
         String tagsParam = par.getParameter("tags", "");        
         if (getLogger().isDebugEnabled()) {
-        	getLogger().debug("tags: " + tagsParam);
+            getLogger().debug("tags: " + tagsParam);
         }        
         this.tags = new HashMap();
         StringTokenizer tokenizer = new StringTokenizer(tagsParam, ",");



Mime
View raw message