Is this safe for providing JSONP?

后端 未结 3 1777
既然无缘
既然无缘 2020-12-24 07:06


        
3条回答
  •  没有蜡笔的小新
    2020-12-24 08:03

    No, if you intend to limit the JSONP to select domains. Specify the encoding too or people who shouldn't be able to access the JSON can possibly do UTF-7 injection attacks. Use this header instead:

    header('Content-Type: application/json; charset=utf-8');
    

    If it's supposed to be a public JSONP service, then yes it is safe, and also use application/javascript instead of application/json.

提交回复
热议问题