-
Notifications
You must be signed in to change notification settings - Fork 72
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
data: / blob: URL mapping #166
Comments
It might make sense to only allow scoping subspaces for special schemes. |
In the current draft spec, the answsers are all Yes, but I think just for generality; (In general, I'm not confident about how to handle cases that look a bit scary like this; If attackers can inject malicious import maps or malicious specifiers, I expect the attackers should be able to inject malicious scripts directly (this depends on import map+CSP design though), so import maps don't increase attack surfaces. On the other hand, conservatively forbidding scary cases (with no valid use cases) might prevent unexpected security issues. Anyway I welcome inputs) |
@bmeck's point about scoping being weird for non-special schemes seems most important here. A scope of Otherwise I tend to lean toward letting people remap specifiers even if those specifiers look like data: URLs, or using import maps to create aliases for data: URLs instead of importing them directly. |
After #176, the latter case ( |
Can you still map identifiers to data URLs? I find myself using things like AMD because I can inline many modules in the page. Import maps + data URLs will provide the same functionality. |
@jakearchibald Could you please elaborate? |
When we built https://proxx.app/, we wanted to improve performance by inlining the JS for the first interaction. The first interaction was a set of modules, some of which weren't exclusive to the first interaction (eg helper functions). When the "later interaction" modules loaded, we wanted them to be able to import modules from the initial set that were inlined into the page. Because AMD allows many modules to be defined in a single script, this was pretty easy to achieve. I'm wondering if import maps can bring the same functionality to standard modules: <script type="importmap">
{
"./utils.mjs": "data:text/javascript;charset=utf-8,export%20const%20log%20%3D%20msg%20%3D%3E%20console.log%28msg%29"
}
</script>
<script type="module">
import { log } from './utils.mjs';
log('Hi!');
</script> In the above, import maps have been used to inline |
Thanks for the explanation. |
Yes.
Currently I expect this is unlikely to happen (I haven't figure out how to achieve this in the spec/impl). |
It will break any relative URLs inside the data url, since they'll become relative to the data url. |
Reflecting WICG/import-maps#227 Bug: 848607, WICG/import-maps#166 Change-Id: Ide80e105fc57dfa35a66051b241b699fa969fcec Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2491594 Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org> Reviewed-by: Kouhei Ueno <kouhei@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Cr-Commit-Position: refs/heads/master@{#833322} GitOrigin-RevId: 895e1cd024248d79a79cc0c2f5ec1fa99e8245b2
Brought up by @jkrems on Twitter - do we permit these mappings? And if so, does that mean that a data: URI with a trailing slash is permitted as a folder mapping?
eg:
would the above map any content after the data URI above to the local URL? And conversely:
would the above map
x/\nconsole.log('hi')
into its executable data URI?The text was updated successfully, but these errors were encountered: