Mock icon indicating copy to clipboard operation
Mock copied to clipboard

响应头Content-Security-Policy "script-src 'self' 导致不能使用eval【BUG】

Open seafronthu opened this issue 3 years ago • 4 comments

 try {
	            // 1. 尝试保持参数的类型
	            /*
	                #24 [Window Firefox 30.0 引用 占位符 抛错](https://github.com/nuysoft/Mock/issues/24)
	                [BX9056: 各浏览器下 window.eval 方法的执行上下文存在差异](http://www.w3help.org/zh-cn/causes/BX9056)
	                应该属于 Window Firefox 30.0 的 BUG
	            */
	            /* jshint -W061 */
	            params = eval('(function(){ return [].splice.call(arguments, 0 ) })(' + params + ')')
	        } catch (error) {
	            // 2. 如果失败,只能解析为字符串
	            // console.error(error)
	            // if (error instanceof ReferenceError) params = parts[2].split(/,\s*/);
	            // else throw error
	            params = parts[2].split(/,\s*/)
	        }

使用mock("@cname")中,发现有使用eval,但该方法在Content-Security-Policy "script-src 'self' 不能使用,于是进入到catch,可是parts下标为2的元素是undefined。 image

seafronthu avatar Mar 29 '23 06:03 seafronthu

可否在服务器上使用?

wll8 avatar Mar 29 '23 08:03 wll8

可否在服务器上使用?

那也行吧,本来想做个纯静态的

seafronthu avatar Apr 26 '23 06:04 seafronthu

这是来自QQ邮箱的假期自动回复邮件。  

sharywkd avatar Apr 26 '23 06:04 sharywkd