You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wookie.apache.org by sc...@apache.org on 2009/12/04 11:20:40 UTC
svn commit: r887150 -
/incubator/wookie/trunk/src/org/apache/wookie/util/StartPageJSParser.java
Author: scottbw
Date: Fri Dec 4 10:20:38 2009
New Revision: 887150
URL: http://svn.apache.org/viewvc?rev=887150&view=rev
Log:
This is a partial fix for WOOKIE-64 that encloses scripts in CDATA sections during parsing, and which are then removed when the widget is saved. This gets rid of the problem of escaping of script content.
Modified:
incubator/wookie/trunk/src/org/apache/wookie/util/StartPageJSParser.java
Modified: incubator/wookie/trunk/src/org/apache/wookie/util/StartPageJSParser.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/util/StartPageJSParser.java?rev=887150&r1=887149&r2=887150&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/util/StartPageJSParser.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/util/StartPageJSParser.java Fri Dec 4 10:20:38 2009
@@ -19,6 +19,7 @@
import java.util.ArrayList;
import java.util.List;
+import org.apache.commons.io.FileUtils;
import org.apache.log4j.Logger;
import org.apache.wookie.beans.ServerFeature;
import org.apache.wookie.feature.IFeature;
@@ -96,7 +97,8 @@
fProps = fCleaner.getProperties();
fProps.setOmitDoctypeDeclaration(false);
fProps.setOmitXmlDeclaration(true);
- fProps.setUseCdataForScriptAndStyle(false);
+ fProps.setUseCdataForScriptAndStyle(true);
+
fProps.setUseEmptyElementTags(false);
try {
TagNode htmlNode = fCleaner.clean(fStartPage);
@@ -164,8 +166,16 @@
for(TagNode node : fScriptList){
headNode.addChild(node);
}
- PrettyXmlSerializer ser = new PrettyXmlSerializer(fProps);
+ PrettyXmlSerializer ser = new PrettyXmlSerializer(fProps);
ser.writeXmlToFile(htmlNode, fStartPage.getAbsolutePath());
+
+ // go back and strip out the CDATA sections we wrapped our scripts in
+ File file = new File(fStartPage.getAbsolutePath());
+ String result = FileUtils.readFileToString(file);
+ String contentResult = result.toString().replaceAll("<!\\[CDATA\\[", "");
+ contentResult = contentResult.toString().replaceAll("\\]\\]>", "");
+ FileUtils.writeStringToFile(file, contentResult);
+
}
}
catch (IOException ex) {