Side navigation
Ticket #2567: ajax-filter.diff
File ajax-filter.diff, 1.1 KB (added by flesler, May 15, 2008 09:09PM UTC)
Index: ajax.js
===================================================================
--- ajax.js (revision 5595)
+++ ajax.js (working copy)
@@ -330,7 +330,7 @@
// Watch for, and catch, XML document parse errors
try {
// process the data (runs the xml through httpData regardless of callback)
- data = jQuery.httpData( xml, s.dataType );
+ data = jQuery.httpData( xml, s.dataType, s.dataFilter );
} catch(e) {
status = "parsererror";
}
@@ -454,7 +454,7 @@
return false;
},
- httpData: function( r, type ) {
+ httpData: function( r, type, filter ) {
var ct = r.getResponseHeader("content-type"),
xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0,
data = xml ? r.responseXML : r.responseText;
@@ -462,6 +462,10 @@
if ( xml && data.documentElement.tagName == "parsererror" )
throw "parsererror";
+ // Allow a pre-filtering function to sanitize the response
+ if( filter )
+ data = filter( data, type );
+
// If the type is "script", eval it in global context
if ( type == "script" )
jQuery.globalEval( data );
Download in other formats:
Original Format
File ajax-filter.diff, 1.1 KB (added by flesler, May 15, 2008 09:09PM UTC)
Index: ajax.js
===================================================================
--- ajax.js (revision 5595)
+++ ajax.js (working copy)
@@ -330,7 +330,7 @@
// Watch for, and catch, XML document parse errors
try {
// process the data (runs the xml through httpData regardless of callback)
- data = jQuery.httpData( xml, s.dataType );
+ data = jQuery.httpData( xml, s.dataType, s.dataFilter );
} catch(e) {
status = "parsererror";
}
@@ -454,7 +454,7 @@
return false;
},
- httpData: function( r, type ) {
+ httpData: function( r, type, filter ) {
var ct = r.getResponseHeader("content-type"),
xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0,
data = xml ? r.responseXML : r.responseText;
@@ -462,6 +462,10 @@
if ( xml && data.documentElement.tagName == "parsererror" )
throw "parsererror";
+ // Allow a pre-filtering function to sanitize the response
+ if( filter )
+ data = filter( data, type );
+
// If the type is "script", eval it in global context
if ( type == "script" )
jQuery.globalEval( data );