Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Well the <code>for(;;);</code> is an infinite loop (you can use Chrome's JavaScript console to run that code in a tab if you want, and then watch the CPU-usage in the task manager go through the roof until the browser kills the tab). </p> <p>So I suspect that maybe it is being put there to frustrate anyone attempting to parse the response using <code>eval</code> or any other technique that executes the returned data.</p> <p>To explain further, it used to be fairly commonplace to parse a bit of JSON-formatted data using JavaScript's <code>eval()</code> function, by doing something like: </p> <p><code>var parsedJson = eval('(' + jsonString + ')')</code>;</p> <p>...this is considered unsafe, however, as if for some reason your JSON-formatted data contains executable JavaScript code instead of (or in addition to) JSON-formatted data then that code will be executed by the <code>eval()</code>. This means that if you are talking with an untrusted server, or if someone compromises a trusted server, then they can run arbitrary code on your page. </p> <p>Because of this, using things like <code>eval()</code> to parse JSON-formatted data is generally frowned upon, and the <code>for(;;);</code> statement in the Facebook JSON will prevent people from parsing the data that way. Anyone that tries will get an infinite loop. So essentially, it's like Facebook is trying to enforce that people work with its API in a way that doesn't leave them vulnerable to future exploits that try to hijack the Facebook API to use as a vector.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload