News for hackers. Stuff that matters.
Re:Throw 1; < don't be evil by mmastrac on Thursday November 25, 2010 @06:55PM (#1941284)
Even better: onload="window.lol&&lol()"

I imagine that this is JS intended to be loaded via XHR only.

Re:Throw 1; < don't be evil by nostrademons on Thursday November 25, 2010 @10:12PM (#1941550)
I was just talking to the guy who added window.lol last Friday. It stands for something that actually made sense in the context of the project, though I forget what exactly.
Re:Throw 1; < don't be evil by Kurtz79 on Friday November 26, 2010 @02:25AM (#1941828)
Don't be evil ? Google ?

Apparently their exception handling does't work very well :)

Re:Throw 1; < don't be evil by klagan on Thursday November 25, 2010 @06:52PM (#1941281)
WTF is that?
Re:Throw 1; < don't be evil by willscott on Thursday November 25, 2010 @06:55PM (#1941285)
Presumably on the google website the script is loaded via an xmlhttp request which then strips the initial text and evals the rest. By added the initial throw 1; they prevent other sites from including the script, since it won't do anything.
Re:Throw 1; < don't be evil by stanleydrew on Thursday November 25, 2010 @07:07PM (#1941300)
Re:Throw 1; < don't be evil by SimonPStevens on Friday November 26, 2010 @04:59AM (#1942037)
Cool site. I've never seen that before. Learn about web security by breaking it.
Re:Throw 1; < don't be evil by verroq on Friday November 26, 2010 @07:57AM (#1942278)
What about hackthissite.org?
Re:Throw 1; < don't be evil by eddieplan9 on Friday November 26, 2010 @08:36AM (#1942348)
That's extremely smart. XMLHttpRequest protects you via the same origin policy. But there are other ways (such as JSONP) to load JavaScript and bypass the same origin policy. It's not like you cannot opt out of things like JSONP, but this trick adds another layer of protection and is particularly useful in fighting XSSI.
Re:Throw 1; < don't be evil by adrianb on Friday November 26, 2010 @06:06AM (#1942132)
If another site would really want to include the script, it could also strip the initial text. Is the purpose only to avoid people from including the script by mistake?
Re:Throw 1; < don't be evil by mcosta on Friday November 26, 2010 @07:18AM (#1942224)
You can't make a XHR request to another domain. You only can include it via a <script> tag and that is going to fail.
Re:Throw 1; &lt; don't be evil by adrianb on Friday November 26, 2010 @08:11AM (#1942297)
Didn't know that. Thanks!
Re:Throw 1; &lt; don't be evil by klagan on Thursday November 25, 2010 @07:06PM (#1941296)
thanks!
Re:Throw 1; &lt; don't be evil by nose on Thursday November 25, 2010 @08:00PM (#1941368)
Re:Throw 1; &lt; don't be evil by DanielRibeiro on Thursday November 25, 2010 @08:08PM (#1941372)
It a XHR response that google search yields on the main page. Just use firebug/google chrome's resource tab to see it.