【问题标题】:node.js express jsonp return typeofnode.js 表达 jsonp 返回 typeof
【发布时间】:2014-09-22 01:04:00
【问题描述】:

不知道为什么,但是我的 Express 应用程序使用 res.jsonp 返回了一些奇怪的东西,如下所示:

/**/ typeof jsonp1406719695757 === 'function' && jsonp1406719695757({"published":true,"can_add_to_cart":true,"updated_at":"2014-01-[...snip...]

只有这个:

jsonp1406719695757({"published":true,"can_add_to_cart":true,"updated_at":"2014-01-[...snip...]

我不明白为什么。有什么想法吗?

【问题讨论】:

  • 它看起来只是在调用它之前验证有一个名为jsonp1406719695757的jsonp回调函数
  • 添加返回这个值的函数,我们猜不出你的代码

标签: javascript node.js express jsonp


【解决方案1】:

如果您查看res.jsonp() 的代码,您会发现comments 在开头解释了额外的内容:

// the /**/ is a specific security mitigation for "Rosetta Flash JSONP abuse"
// the typeof check is just to reduce client error noise
body = '/**/ typeof ' + callback + ' === \'function\' && ' + callback + '(' + body + ');';

【讨论】:

  • 哦,没错,我发现它也适用于该字符串,CORS 域和重定向存在问题。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-09-23
  • 1970-01-01
  • 1970-01-01
  • 2011-09-23
  • 1970-01-01
相关资源
最近更新 更多