How can I make external code 'safe' to run? Just ban eval()?

前端 未结 6 1033
情书的邮戳
情书的邮戳 2020-12-30 14:40

I\'d like to be able to allow community members to supply their own javascript code for others to use, because the users\' imaginations are collectively far greater than any

6条回答
  •  庸人自扰
    2020-12-30 14:58

    Filtering out eval probably doesn't work. I imagine that you could hack round it like this: window['ev' + 'al']('alert("hello world");');. You could of course replace the eval function...

提交回复
热议问题