openscad.xyz support for "data:" URI scheme would be cool
-
"https://openjscad.xyz?uri=..." is cool.
"data:" URI scheme does not work for openjscad.xyz:
https://en.wikipedia.org/wiki/Data_URI_scheme#SyntaxI use this working minimal JSCAD file:
https://www.openjscad.xyz/?uri=https://stamm-wilbrandt.de/en/forum/JSCAD.minimal.jsmodule.exports=function main(){return require('@jscad/modeling').primitives.sphere({radius: 50})}This URI does not work:
https://openjscad.xyz/?uri=data:text/html;module.exports=function main(){return require('@jscad/modeling').primitives.sphere({radius: 50})}Base64 encoding and using application/json does not work either:
https://openjscad.xyz/?uri=data:application/json;base64,bW9kdWxlLmV4cG9ydHM9ZnVuY3Rpb24gbWFpbigpe3JldHVybiByZXF1aXJlKCdAanNjYWQvbW9kZWxpbmcnKS5wcmltaXRpdmVzLnNwaGVyZSh7cmFkaXVzOiA1MH0pfQo=It would be cool to have "data:" links working with openjscad.xyz, because that would allow to share JSCAD files without storing them anywhere — they are stored as part of the link ...
For looking where&how to add "data:" scheme: How is "dist/jscad-web.min.js" generated?
-
@Hermann-SW thanks for the suggestions.
The support of data URL contents is not trivia, especially if you expect the 'data' to be evaluated as a JavaScript module. That's kind of breaking every security rule in the book.
However, the support for DATA formats might be possible, such as supplying JSON contents. But that would be very limited.
I think the real solution would be allowing the require() to include modules from remote sites. There are many such requests (issues) for the same functionality.
If you have any ideas then let's discuss via the GitHub discussions. There may be a solution, as modern browsers have a lot of functionality.
-
@z3dev Thanks, I see your point wrt security.
But what is the difference of ...uri=data:... to this openscad.xyz link with model wrt security? In case you eval the uri= specified file (and that seems to be the case because the model gets rendered in browser) you break the same security rules ...
https://www.openjscad.xyz/?uri=https://stamm-wilbrandt.de/en/forum/JSCAD.minimal.js -
@Hermann-SW Good questions...
The website has a little Perl script that does the download of the requested file, and checks the content. This does two things; only know file types are allowed, and this goes around CORS.
https://github.com/jscad/OpenJSCAD.org/blob/master/packages/web/remote.pl
I guess that supporting data URL would be possible, but there would have to be some similar checks for data type, etc.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login