Author: mgrigorov
Date: Fri Feb 18 09:41:58 2011
New Revision: 1071931

URL: http://svn.apache.org/viewvc?rev=1071931&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/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js

Modified: 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js
URL: 
http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js?rev=1071931&r1=1071930&r2=1071931&view=diff
==============================================================================
--- 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js
 (original)
+++ 
wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js
 Fri Feb 18 09:41:58 2011
@@ -1500,14 +1500,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