-
Notifications
You must be signed in to change notification settings - Fork 111
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
CSP issue because the TransformModal uses new Function
#465
Comments
That is a good point. The editor has a flexible API to define one or multiple custom query languages, but right now the JavaScript query language is always included since it is the default one: https://github.com/josdejong/svelte-jsoneditor/blob/main/src/lib/components/JSONEditor.svelte#L88 I'm not sure what would be the best way to go about this:
Any thoughts? |
I think the function executeQuery(json, query, callback) {} or async function executeQuery(json, query) {} There should be an option for developers to override this with a custom function. In many cases, |
Great idea to support async results in |
I'm working on a safe and very lightweight JSON query language to include as default in |
I was thinking about a good use case where you want to be able to run In my experience, executing a query runs about instantly, it maybe takes up to 1 second or so for a large 500 MB JSON document. So no need to run it in a separate worker or anything. That would even work worse: copying the document to a worker context and back would already take more time than the actual transform operation. Do you have a concrete use case for the need for an async |
Defaulting to asynchronous operations is always a good idea. With this general-purpose library, there's a chance that someone might want to override the function, and it's likely that the parser or interpreter will return results asynchronously. Like the worker method I've mentioned. |
Thanks for your feedback. An async API is indeed the most powerful and in general a good idea, however it will also require work to properly implement it (we need to show a loading icon after a delay, ensure only the results of the last request are displayed on screen when multiple requests are made shortly after each other, etc). I'm not going to implement that unless we have a concrete and valid use case for it (YAGNI). |
new Function
new Function
new Function
Since There are only two pieces of code left containing
When you're using tree-shaking in your project, you'll not end up with the code of (1) as long as you don't use these plugins. The same should work for Ajv (2), but Ajv doesn't yet allow tree shaking it. This is addressed via ajv-validator/ajv#2479 but this fix is not yet published. As a workaround, you can manually add the field |
I'll now close this issue. The last open end will be resolved with the first next release of Ajv. |
The "Transform" feature uses
new Function
, which may be restricted in certain cases due to CSP limitations. Could we have a custom async eval method that allows using a worker to execute the user function and return the value asynchronously?The text was updated successfully, but these errors were encountered: