Changeset 8608
- Timestamp:
- 05/14/07 14:50:50 (19 months ago)
- Location:
- branches/0.4
- Files:
-
- 2 modified
- 2 copied
-
src/io/BrowserIO.js (modified) (2 diffs)
-
src/io/common.js (modified) (1 diff)
-
tests/io/data-json-comment-filtered.js (copied) (copied from trunk/tests/io/data-json-comment-filtered.js)
-
tests/io/test_BrowserIO.json-comment-filtered.html (copied) (copied from trunk/tests/io/test_BrowserIO.json-comment-filtered.html)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.4/src/io/BrowserIO.js
r8514 r8608 282 282 ret = null; 283 283 } 284 }else if(kwArgs.mimetype == "text/json" || kwArgs.mimetype== "application/json"){284 }else if(kwArgs.mimetype.substr(0, 9) == "text/json" || kwArgs.mimetype.substr(0, 16) == "application/json"){ 285 285 try{ 286 ret = dj_eval("("+ http.responseText+")");286 ret = dj_eval("("+kwArgs.jsonFilter(http.responseText)+")"); 287 287 }catch(e){ 288 288 dojo.debug(e); … … 398 398 // multi-part mime encoded and avoid using this transport for those 399 399 // requests. 400 var mlc = kwArgs["mimetype"].toLowerCase()||""; 400 401 return hasXmlHttp 401 && dojo.lang.inArray(["text/plain", "text/html", "application/xml", "text/xml", "text/javascript", "text/json", "application/json"], (kwArgs["mimetype"].toLowerCase()||"")) 402 && ( 403 ( 404 dojo.lang.inArray([ 405 "text/plain", "text/html", "application/xml", 406 "text/xml", "text/javascript" 407 ], mlc 408 ) 409 ) || ( 410 mlc.substr(0, 9) == "text/json" || mlc.substr(0, 16) == "application/json" 411 ) 412 ) 402 413 && !( kwArgs["formNode"] && dojo.io.formHasFile(kwArgs["formNode"]) ); //boolean 403 414 } -
branches/0.4/src/io/common.js
r6674 r8608 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