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

unsafe-eval, required for nunjucks and RJSF, isn't allowed in MV3 #4693

Closed
fregante opened this issue Nov 22, 2022 · 5 comments
Closed

unsafe-eval, required for nunjucks and RJSF, isn't allowed in MV3 #4693

fregante opened this issue Nov 22, 2022 · 5 comments
Labels

Comments

@fregante
Copy link
Contributor

fregante commented Nov 22, 2022

This line is causing an error for every brick with text input. I don't think there's any way around this, as it's not a CWS-related restriction as previously suggested, but a hardcoded MV3 limitation that blocks eval entirely.

new Template(expression.__value__, undefined, undefined, true);

Screen Shot

Previously mentioned

External links (no solution)

Repro

  1. Build MV3

    MV=3 npm run watch
  2. Open any bricks in the page editor

@fregante fregante added the mv3 label Nov 22, 2022
@fregante fregante changed the title unsafe-eval, required for nunjucks, isn't allowed in MV3 unsafe-eval, required for nunjucks and RJSF, isn't allowed in MV3 Nov 22, 2022
@twschiller
Copy link
Contributor

We have a couple options here I think:

I had added this point to the agenda of the w3c kickoff meeting on userscripts, but unfortunately had the drop off the call before it was discussed. I will prioritize clarifying the behavior for MV3

@fregante
Copy link
Contributor Author

fregante commented Nov 22, 2022

Note that neither one is available from the background worker because they either require a full tab or an iframe. Also possible bug that might affect us:

Sandbox

The sandbox sounds like the right way to do this, either in the content script or page editor:

Userscripts

Unless Userscripts directly support unsafe-eval within them (which is TBD), they could become incredibly involved and slow due to messaging and probably because the "userscript" would be the raw compiled nunjucks/RJSF javascript string. Let's keep this as a last resort (also because they don't exist in Chrome yet).

Related: https://developer.chrome.com/docs/extensions/mv3/known-issues/#userscript-managers-support

@fregante
Copy link
Contributor Author

I can work on the sandbox issue for this then. I will look into implementing a barebones connectable sandbox, possibly one that pre-loads nunjucks in order to evaluate the templates in it:

@twschiller
Copy link
Contributor

twschiller commented Nov 22, 2022

Note that neither one is available from the background worker because they either require a full tab or an iframe

IIRC, we don't evaluate templates from the background page anyway. (The original design always used contentScript due to security/performance reasons)

If we do need to run from background page, there's an offscreen documents proposal: w3c/webextensions#170

@fregante
Copy link
Contributor Author

unsafe-eval is available in the sandbox 🎉

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

No branches or pull requests

2 participants