Author: scottbw
Date: Tue Feb 26 11:05:06 2013
New Revision: 1450132

URL: http://svn.apache.org/r1450132
Log:
Deprecated our custom HtmlSerializer implementation and replaced with the 
default SimpleHtmlSerializer from HtmlCleaner; this does the same job when 
configured with the allowHtmlInsideAttributes property set. Also replaced 
"getChildren" with "getChildTagNodes" as in future versions of HtmlCleaner this 
method is not guaranteed to always return only TagNode objects.

Modified:
    wookie/trunk/src/org/apache/wookie/util/html/HtmlCleaner.java
    wookie/trunk/src/org/apache/wookie/util/html/HtmlSerializer.java

Modified: wookie/trunk/src/org/apache/wookie/util/html/HtmlCleaner.java
URL: 
http://svn.apache.org/viewvc/wookie/trunk/src/org/apache/wookie/util/html/HtmlCleaner.java?rev=1450132&r1=1450131&r2=1450132&view=diff
==============================================================================
--- wookie/trunk/src/org/apache/wookie/util/html/HtmlCleaner.java (original)
+++ wookie/trunk/src/org/apache/wookie/util/html/HtmlCleaner.java Tue Feb 26 
11:05:06 2013
@@ -21,6 +21,7 @@ import java.util.List;
 
 import org.htmlcleaner.CleanerProperties;
 import org.htmlcleaner.DoctypeToken;
+import org.htmlcleaner.SimpleHtmlSerializer;
 import org.htmlcleaner.TagNode;
 
 /**
@@ -66,6 +67,11 @@ public class HtmlCleaner implements IHtm
                properties.setAdvancedXmlEscape(true);
                properties.setRecognizeUnicodeChars(false);
                
+               //
+               // Ensure we don't escape scripts within event handlers
+               //
+               properties.setAllowHtmlInsideAttributes(true);
+               
        }
        
        /* (non-Javadoc)
@@ -138,9 +144,8 @@ public class HtmlCleaner implements IHtm
        public void process(Writer writer) throws IOException{
                if (reader == null) throw new IOException("No file has been 
specified to process");
                if (writer == null) throw new IOException("No writer provided");
-               replaceUserScripts();
-               HtmlSerializer ser = new HtmlSerializer(properties);    
-               ser.writeXml(htmlNode, writer, "UTF-8");
+               replaceUserScripts();   
+               new SimpleHtmlSerializer(properties).write(htmlNode, writer, 
"UTF-8");
        }
        
 
@@ -162,7 +167,7 @@ public class HtmlCleaner implements IHtm
         */
        @SuppressWarnings("unchecked")
        private void getUserScripts(){
-               List<TagNode> children = headNode.getChildren();                
+               List<TagNode> children = headNode.getChildTagList();            
                for(TagNode child : children){                                  
        
                        if(child.getName().equals(SCRIPT_TAG)){                 
        
                                scriptList.add(child);  

Modified: wookie/trunk/src/org/apache/wookie/util/html/HtmlSerializer.java
URL: 
http://svn.apache.org/viewvc/wookie/trunk/src/org/apache/wookie/util/html/HtmlSerializer.java?rev=1450132&r1=1450131&r2=1450132&view=diff
==============================================================================
--- wookie/trunk/src/org/apache/wookie/util/html/HtmlSerializer.java (original)
+++ wookie/trunk/src/org/apache/wookie/util/html/HtmlSerializer.java Tue Feb 26 
11:05:06 2013
@@ -30,6 +30,7 @@ import org.htmlcleaner.XmlSerializer;
  * event handler attributes such as "onClick". In other respects it is 
identical 
  * to SimpleXmlSerializer.
  */
+@Deprecated
 public class HtmlSerializer extends XmlSerializer {
        
        /**


Reply via email to