<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>jQuery Grid Plugin - jqGrid - Topic: jQgrid does JSON-parsing via "eval"</title>
	<link>http://www.trirand.com/blog/?page_id=393/bugs/jqgrid-does-json-parsing-via-eval</link>
	<description><![CDATA[Grid plugin]]></description>
	<generator>Simple:Press Version 5.7.5.3</generator>
	<atom:link href="http://www.trirand.com/blog/?page_id=393/bugs/jqgrid-does-json-parsing-via-eval/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>ghum on jQgrid does JSON-parsing via "eval"</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/jqgrid-does-json-parsing-via-eval#p9733</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/jqgrid-does-json-parsing-via-eval#p9733</guid>
        	        	<description><![CDATA[<p>Tony,</p>
<p>&#62; Thanks. Why do you think that this is a bug?</p>
<p>"bug" may be a hard word 🙂 But there is no forum for "potential security risks" ....</p>
<p>It may be an unecessary security risk - as eval() may have side effects. (probably the reason for the "protect against while(1) at the beginning)</p>
<p>Mozilla took its time to implement the global JSON-object for a reason - as eval() has to take more care then "unserialize an object". I did not time it, but would bet that on recent browser native JSON.parse is faster then eval()</p>
<p>Thanks for that .extend - that can help me in other situations, too!</p>
<p>best wishes</p>
</p>
<p>Harald</p></p>
]]></description>
        	        	<pubDate>Tue, 15 Sep 2009 06:40:13 +0300</pubDate>
        </item>
        <item>
        	<title>tony on jQgrid does JSON-parsing via "eval"</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/jqgrid-does-json-parsing-via-eval#p9706</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/jqgrid-does-json-parsing-via-eval#p9706</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>Thanks. Why do you think that this is a bug?</p>
<p>Also do the following - after you load the jqGrid JS files include in your load the ultra-opimized JSON-parser and do the following</p>
<p><input type='button' class='sfcodeselect' name='sfselectit3434' value='Select Code' data-codeid='sfcode3434' /></p>
<div class='sfcode' id='sfcode3434'>
<p>&#60;script&#62;</p>
<p>$.extend($.jgrid, {</p>
<p>&#160;&#160;&#160; parse : function(jsonString) {<br />&#160;&#160;&#160; &#160;&#160;&#160; return JSON.parse(jsonString);<br />&#160;&#160;&#160; }</p>
<p>})</p>
<p>&#60;/script&#62;</p>
</div>
<p>This will overwrite the jqGrid parse function.</p>
<p>Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Mon, 14 Sep 2009 22:35:18 +0300</pubDate>
        </item>
        <item>
        	<title>ghum on jQgrid does JSON-parsing via "eval"</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/jqgrid-does-json-parsing-via-eval#p9696</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/jqgrid-does-json-parsing-via-eval#p9696</guid>
        	        	<description><![CDATA[<p>within grid.base.js, there is:</p>
</p>
<p>parse : function(jsonString) {<br />&#160;&#160;&#160; &#160;&#160;&#160; var js = jsonString;<br />&#160;&#160;&#160; &#160;&#160;&#160; if (js.substr(0,9) == "while(1);") { js = js.substr(9); }<br />&#160;&#160;&#160; &#160;&#160;&#160; if (js.substr(0,2) == "/*") { js = js.substr(2,js.length-4); }<br />&#160;&#160;&#160; &#160;&#160;&#160; if(!js) { js = "{}"; }<br />&#160;&#160;&#160; &#160;&#160;&#160; with(window) {<br />&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; return&#160; eval(&#39;(&#39;+js+&#39;)&#39;);<br />&#160;&#160;&#160; &#160;&#160;&#160; }<br />&#160;&#160;&#160; },</p>
</p>
<p>using eval() poses quite some hacking potential; and better browser nowadays have included an ultra-opimized JSON-parser with the global JSON object. An easy substitute is to:</p>
</p>
<p>a) include</p>
<p><a href="http://www.json.org/json2.js" rel="nofollow" target="_blank">http://www.json.org/json2.js</a></p>
<p>(public domain code)</p>
<p>b) replace that lines with<br />&#160;&#160;&#160; parse : function(jsonString) {<br />&#160;&#160;&#160; &#160;&#160;&#160; return JSON.parse(jsonString);<br />&#160;&#160;&#160; },</p>
<p>json2.js makes sure that the native browser JSON-parser gets used if available, and otherwise is better protected against injection of malicous code.</p>
</p>
<p>Harald</p>
]]></description>
        	        	<pubDate>Mon, 14 Sep 2009 10:22:34 +0300</pubDate>
        </item>
</channel>
</rss>