Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Use fetch infrastructure to fetch source maps #27

Merged
merged 4 commits into from
Jan 25, 2024

Conversation

nicolo-ribaudo
Copy link
Member

Closes tc39/ecma426#30

This PR uses the fetch spec to fetch source maps, relieving us from a couple responsibility:

source-map.bs Outdated
1. Let |request| be a new [=request=] whose [=request/URL=] is |url|.
1. [=Fetch=] |request| with [=processResponseConsumeBody=] set to the following steps given [=response=] <var ignore>response</var> and null, failure, or a [=byte sequence=] |bodyBytes|:
1. If |bodyBytes| is null or failure, [=reject=] |promise| with a {{TypeError}} and abort these steps.
1. Let |sourceMap| be the result of [=parsing JSON bytes to a JavaScript value=] given |bodyBytes|.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is basically JSON.parse(utf8decode(bodyBytes)). There is also the option of returning an "internal spec value" rather than a JS object, but our spec is so high level that it doesn't really matter.

@nicolo-ribaudo
Copy link
Member Author

Oh I should also merge http://localhost:4507/source-map.html#json-over-http-transport in this section

source-map.bs Outdated
Comment on lines 439 to 441
1. If |url|'s [=url/scheme=] is "<code>http</code>" and |bodyBytes| [=byte sequence/starts with=] \`<code>)]}'</code>\`, then:
1. [=While=] |bodyBytes|'s [=byte sequence/length=] is not 0 and |bodyBytes|'s 0th byte is not 0x0A (LF) or 0x0D (CR):
1. remove the 0th byte from |bodyBytes|.
Copy link
Member Author

@nicolo-ribaudo nicolo-ribaudo Jan 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Do we know if this is only for HTTP or also for HTTPS? (answer by @jridgewell: yes)
  • Do we know what "ignore the first line" means? Some possible sets of line terminators are:
    • \n and \r (what HTTP defines as line terminators)
    • \n, \r, U+2028, U+2029 (what JS defines as line terminators)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does anyone have bandwidth to test this in some browsers?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://developer.chrome.com/blog/sourcemaps#potential_xssi_issues, the answer could also be "just \n"

@mitsuhiko mitsuhiko merged commit 9cec4a8 into tc39:main Jan 25, 2024
2 checks passed
github-actions bot added a commit that referenced this pull request Jan 25, 2024
SHA: 9cec4a8
Reason: push, by mitsuhiko

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@nicolo-ribaudo nicolo-ribaudo deleted the fetch branch January 26, 2024 09:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hardening: Compression
4 participants