Author: mgrigorov
Date: Fri Feb 18 09:40:02 2011
New Revision: 1071930

URL: http://svn.apache.org/viewvc?rev=1071930&view=rev
Log:
WICKET-3420 javascript with a less than character ("<") fails to execute when 
added through a header contribution in ajax response

Add logging for the cases when there is an error in the parsing of XML with 
DOMParser


Modified:
    wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/wicket-ajax.js

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/wicket-ajax.js
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/wicket-ajax.js?rev=1071930&r1=1071929&r2=1071930&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/wicket-ajax.js 
(original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/ajax/wicket-ajax.js 
Fri Feb 18 09:40:02 2011
@@ -1478,14 +1478,37 @@ Wicket.Head.Contributor.prototype = {
                return xmldoc;  
        },
        
+       // checks whether the passed node is the special "parsererror" 
+       // created by DOMParser if there is a error in XML parsing
+       _checkParserError: function(node) {
+               var result = false;
+               
+               if (node.tagName != null && node.tagName.toLowerCase() == 
"parsererror") {
+                       Wicket.Log.error("Error in parsing: " + 
node.textContent);
+                       result = true;
+               }
+               return result;
+       },
+       
        // Processes the parsed header contribution
        processContribution: function(steps, headerNode) {
                var xmldoc = this.parse(headerNode);
                var rootNode = xmldoc.documentElement;
 
+               // Firefox and Opera reports the error in the documentElement
+               if (this._checkParserError(rootNode)) {
+                       return;
+               }
+
                // go through the individual elements and process them 
according to their type
                for (var i = 0; i < rootNode.childNodes.length; i++) {
                        var node = rootNode.childNodes[i];                      
+
+                       // Chromium reports the error as a child node
+                       if (this._checkParserError(node)) {
+                               return;
+                       }
+
                        if (node.tagName != null) {
                                var name = node.tagName.toLowerCase();
                                


Reply via email to