<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>
<channel>
	<title>Comments on: Gravity never sleeps (notations that use eval)</title>
	<atom:link href="http://cmsmcq.com/mib/?feed=rss2&#038;p=7" rel="self" type="application/rss+xml" />
	<link>http://cmsmcq.com/mib/?p=7</link>
	<description>CMSMcQ's klog</description>
	<pubDate>Fri, 10 Sep 2010 11:50:48 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: cmsmcq</title>
		<link>http://cmsmcq.com/mib/?p=7&cpage=1#comment-147</link>
		<dc:creator>cmsmcq</dc:creator>
		<pubDate>Mon, 28 Jan 2008 17:32:33 +0000</pubDate>
		<guid isPermaLink="false">http://cmsmcq.com/mib/?p=7#comment-147</guid>
		<description>I'm not entirely certain that I understand Tyler Close's comment.  The last time I looked, the innerHTML property defined in some browsers was not part of the DOM specification, and it doesn't seem to make sense in an XML interface, as opposed to an (X)HTML interface. 

It is quite true that for any Web browser that automatically executes javascript contained in an innerHTML property, innerHTML offers the same security issues as JSON.  And if innerHTML, and the execution of Javascript in any page one loads in a browser, are both OK, then in a browser JSON must be OK, since it doesn't make things any worse.  Doug Crockford made this point during the discussion in Boston in December.  (Of course, he also said quite clearly that he thought browser security was a huge problem.) But as my colleague Thomas Roessler (see link above) has pointed out, Javascript and JSON are not used only in browser contexts.</description>
		<content:encoded><![CDATA[<p>I&#8217;m not entirely certain that I understand Tyler Close&#8217;s comment.  The last time I looked, the innerHTML property defined in some browsers was not part of the DOM specification, and it doesn&#8217;t seem to make sense in an XML interface, as opposed to an (X)HTML interface. </p>
<p>It is quite true that for any Web browser that automatically executes javascript contained in an innerHTML property, innerHTML offers the same security issues as JSON.  And if innerHTML, and the execution of Javascript in any page one loads in a browser, are both OK, then in a browser JSON must be OK, since it doesn&#8217;t make things any worse.  Doug Crockford made this point during the discussion in Boston in December.  (Of course, he also said quite clearly that he thought browser security was a huge problem.) But as my colleague Thomas Roessler (see link above) has pointed out, Javascript and JSON are not used only in browser contexts.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tyler Close</title>
		<link>http://cmsmcq.com/mib/?p=7&cpage=1#comment-103</link>
		<dc:creator>Tyler Close</dc:creator>
		<pubDate>Mon, 21 Jan 2008 17:09:56 +0000</pubDate>
		<guid isPermaLink="false">http://cmsmcq.com/mib/?p=7#comment-103</guid>
		<description>Of course all the arguments presented in this blog post also apply to XML, since the easiest way to update a DOM tree is to write code like: "document.body.innerHTML = "". This expression is essentially eval() for XML and it is the path of least resistance when using XML markup.

On the other hand, the json.js file from json.org provides an easy to use API for safely parsing a JSON string with: "some JSON data".parseJSON(). That's at least as easy to use as eval() and is safe. There's nothing quite so easy and safe in the XML world, though it may be possible to create such an API, and that's the core point to understand. The issues you raised are about the parsing API, not the data format syntax. An API that lets the programmer easily demand: "Overwrite my data model with this data I got from the network and haven't vetted" is asking for trouble. You can implement such an API for any data format syntax, as evidenced by both XML and JSON parsing APIs in current browsers. Avoiding this kind of problem requires a level of competence from the browser API designer. You can't solve this problem just by your choice of data format syntax.</description>
		<content:encoded><![CDATA[<p>Of course all the arguments presented in this blog post also apply to XML, since the easiest way to update a DOM tree is to write code like: &#8220;document.body.innerHTML = &#8220;&#8221;. This expression is essentially eval() for XML and it is the path of least resistance when using XML markup.</p>
<p>On the other hand, the json.js file from json.org provides an easy to use API for safely parsing a JSON string with: &#8220;some JSON data&#8221;.parseJSON(). That&#8217;s at least as easy to use as eval() and is safe. There&#8217;s nothing quite so easy and safe in the XML world, though it may be possible to create such an API, and that&#8217;s the core point to understand. The issues you raised are about the parsing API, not the data format syntax. An API that lets the programmer easily demand: &#8220;Overwrite my data model with this data I got from the network and haven&#8217;t vetted&#8221; is asking for trouble. You can implement such an API for any data format syntax, as evidenced by both XML and JSON parsing APIs in current browsers. Avoiding this kind of problem requires a level of competence from the browser API designer. You can&#8217;t solve this problem just by your choice of data format syntax.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Cowan</title>
		<link>http://cmsmcq.com/mib/?p=7&cpage=1#comment-13</link>
		<dc:creator>John Cowan</dc:creator>
		<pubDate>Tue, 01 Jan 2008 15:45:49 +0000</pubDate>
		<guid isPermaLink="false">http://cmsmcq.com/mib/?p=7#comment-13</guid>
		<description>Arrgh, I didn't mean to post yet...

Anyway, your general point is perfectly sound, and is one of the reasons why I refuse to use C++ -- there is one right way to do each thing, and 49 wrong ways, and the simple and obvious way is always among the 49.</description>
		<content:encoded><![CDATA[<p>Arrgh, I didn&#8217;t mean to post yet&#8230;</p>
<p>Anyway, your general point is perfectly sound, and is one of the reasons why I refuse to use C++ &#8212; there is one right way to do each thing, and 49 wrong ways, and the simple and obvious way is always among the 49.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Cowan</title>
		<link>http://cmsmcq.com/mib/?p=7&cpage=1#comment-12</link>
		<dc:creator>John Cowan</dc:creator>
		<pubDate>Tue, 01 Jan 2008 15:44:21 +0000</pubDate>
		<guid isPermaLink="false">http://cmsmcq.com/mib/?p=7#comment-12</guid>
		<description>I think it's also worth mentioning, though, that a fairly short and simple regex defangs JSON completely; if you don't eval any JSON that does not match ^("(\\.&#124;[^"\\\n\r])*?"&#124;[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$', you are fairly safe.</description>
		<content:encoded><![CDATA[<p>I think it&#8217;s also worth mentioning, though, that a fairly short and simple regex defangs JSON completely; if you don&#8217;t eval any JSON that does not match ^(&#8221;(\\.|[^"\\\n\r])*?&#8221;|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$&#8217;, you are fairly safe.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
