Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
seafronthu opened this issue Mar 29, 2023 · 3 comments

Comments

@seafronthu
Copy link

seafronthu commented Mar 29, 2023

 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 seafronthu changed the title 严格模式下不能使用mock("@cname") 严格模式下不能使用mock("@cname")【BUG】 Mar 29, 2023
@seafronthu seafronthu changed the title 严格模式下不能使用mock("@cname")【BUG】 响应头Content-Security-Policy "script-src 'self' 导致不能使用eval【BUG】 Mar 29, 2023
@wll8
Copy link

wll8 commented Mar 29, 2023

可否在服务器上使用?

@seafronthu
Copy link
Author

可否在服务器上使用?

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

@sharywkd
Copy link

sharywkd commented Apr 26, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants