Changeset 7811
- Timestamp:
- 03/27/07 16:17:07 (2 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 2 modified
-
src/io/BrowserIO.js (modified) (2 diffs)
-
src/io/common.js (modified) (1 diff)
-
tests/io/data-json-comment-filtered.js (added)
-
tests/io/test_BrowserIO.json-comment-filtered.html (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/io/BrowserIO.js
r7146 r7811 281 281 ret = null; 282 282 } 283 }else if(kwArgs.mimetype == "text/json" || kwArgs.mimetype== "application/json"){283 }else if(kwArgs.mimetype.substr(0, 9) == "text/json" || kwArgs.mimetype.substr(0, 16) == "application/json"){ 284 284 try{ 285 ret = dj_eval("("+ http.responseText+")");285 ret = dj_eval("("+kwArgs.jsonFilter(http.responseText)+")"); 286 286 }catch(e){ 287 287 dojo.debug(e); … … 397 397 // multi-part mime encoded and avoid using this transport for those 398 398 // requests. 399 var mlc = kwArgs["mimetype"].toLowerCase()||""; 399 400 return hasXmlHttp 400 && dojo.lang.inArray(["text/plain", "text/html", "application/xml", "text/xml", "text/javascript", "text/json", "application/json"], (kwArgs["mimetype"].toLowerCase()||"")) 401 && ( 402 ( 403 dojo.lang.inArray([ 404 "text/plain", "text/html", "application/xml", 405 "text/xml", "text/javascript" 406 ], mlc 407 ) 408 ) || ( 409 mlc.substr(0, 9) == "text/json" || mlc.substr(0, 16) == "application/json" 410 ) 411 ) 401 412 && !( kwArgs["formNode"] && dojo.io.formHasFile(kwArgs["formNode"]) ); //boolean 402 413 } -
trunk/src/io/common.js
r6675 r7811 113 113 /** Prevent the browser from caching this by adding a query string argument to the URL */ 114 114 preventCache: false, 115 116 jsonFilter: function(value){ 117 if( (this.mimetype == "text/json-comment-filtered")|| 118 (this.mimetype == "application/json-comment-filtered") 119 ){ 120 var cStartIdx = value.indexOf("\/*"); 121 var cEndIdx = value.lastIndexOf("*\/"); 122 if((cStartIdx == -1)||(cEndIdx == -1)){ 123 dojo.debug("your JSON wasn't comment filtered!"); // FIXME: throw exception instead? 124 return ""; 125 } 126 return value.substring(cStartIdx+2, cEndIdx); 127 } 128 dojo.debug("please consider using a mimetype of text/json-comment-filtered to avoid potential security issues with JSON endpoints"); 129 return value; 130 }, 115 131 116 132 // events stuff