Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook graph api JSONP format , what does the /* */ in first line signify?

I noticed an empty comment block in JSONP output returned by facebook graph api for all methods.

URL that I called :

https://graph.facebook.com/NUMERIC_FACEBOOK_ID/friends?access_token=ACCESS_TOKEN_STRING&callback=theGreatFunction

The JSONP output is :

/**/ theGreatFunction({
   "data": [
      {
         "name": "First Friend",
         "id": "XXXX"
      },
      {
         "name": "Second Friend",
         "id": "XXXXXX"
      },
     ........

My question is : What does the empty comment block /* */ before the callback function signify ? Does it have a peculiar purpose ? Does it fix any known javascript gotcha ?

like image 204
DhruvPathak Avatar asked Nov 07 '11 09:11

DhruvPathak


1 Answers

We added this to protect against an attack where a third party site bypasses the content-type of the response by doing:

<object type="application/x-shockwave-flash"
 data="http://graph.facebook.com?callback=[specifically crafted flash bytes]">
</object>

Google does something similar, except they use //... + \n (e.g. http://www.google.com/calendar/feeds/[email protected]/public/full?alt=json&callback=foo)

like image 160
Alok Avatar answered Oct 17 '22 22:10

Alok