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

Commit 3682cc1

Browse files
concavelenzjkrems
authored andcommitted
Source Map Revision 3 Proposal as of 2013-02-19
Co-authored-by: John Lenz <[email protected]>
1 parent 5508ea8 commit 3682cc1

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

source-map-rev3.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ May 2, 2012 | John Lenz | HTTP header and CC-BY-SA license
2020
July 30, 2012 | John Lenz | Modified recommended HTTP header name.
2121
August 20, 2012 | John Lenz | Add CSS linkage recommendation
2222
October 24, 2012 | John Lenz | Add clarifying section on source locations.
23+
February 19, 2013 | John Lenz | Add “sourcesContent” line to support self contained source maps.<p>Added note regarding using data uri to load source maps.
2324

2425
## License
2526

@@ -65,9 +66,10 @@ Source Mapping URL | The URL referencing the location of a source map from the g
6566
3. `file: "out.js",`
6667
4. `sourceRoot : "",`
6768
5. `sources: ["foo.js", "bar.js"],`
68-
6. `names: ["src", "maps", "are", "fun"],`
69-
7. `mappings: "AA,AB;;ABCDE;"`
70-
8. `}`
69+
6. `sourcesContent: [null, null],`
70+
7. `names: ["src", "maps", "are", "fun"],`
71+
8. `mappings: "AA,AB;;ABCDE;"`
72+
9. `}`
7173

7274
Line 1: The entire file is a single JSON object
7375

@@ -79,9 +81,11 @@ Line 4: An optional source root, useful for relocating source files on a server
7981

8082
Line 5: A list of original sources used by the “mappings” entry.
8183

82-
Line 6: A list of symbol names used by the “mappings” entry.
84+
Line 6: An optional list of source content, useful when the “source” can’t be hosted. The contents are listed in the same order as the sources in line 5. “null” may be used of some original sources should be retrieved by name.
8385

84-
Line 7: A string with the encoded mapping data.
86+
Line 7: A list of symbol names used by the “mappings” entry.
87+
88+
Line 8: A string with the encoded mapping data.
8589

8690
The “mappings” data is broken down as follows:
8791

@@ -223,6 +227,8 @@ This recommendation works well for JavaScript, it is expected that other source
223227

224228
Note: &lt;url> is a URL as defined in RFC3986; in particular, characters outside the set permitted to appear in URIs must be percent-encoded.
225229

230+
Note: &lt;url> maybe a data URI. Using a data URI along with “sourcesContent” allow for a completely self-contained source-map.
231+
226232
Regardless of the method used to retrieve the source mapping URL the same process is used to resolve it, which is as follows:
227233

228234
When the source mapping URL is not absolute, then it is relative to the generated code’s “source origin”. The source origin is determined by one of the following cases:
@@ -264,6 +270,6 @@ However, It is unclear what a “source map reference” looks like in anything
264270

265271
### JSON over HTTP Transport
266272

267-
[XSSI](http://googleonlinesecurity.blogspot.com/2011/05/website-security-for-webmasters.html) attacks <span style="text-decoration:underline;">(https://wiki.corp.google.com/twiki/bin/view/Main/ISETeamScriptInclusion)</span> could potentially make source maps available to attackers by doing a direct script src to a source map after overriding the Array constructor. This can be effectively prevented by preprending a JavaScript syntax error to the start of the response.
273+
[XSSI](http://googleonlinesecurity.blogspot.com/2011/05/website-security-for-webmasters.html) attacks could potentially make source maps available to attackers by doing a direct script src to a source map after overriding the Array constructor. This can be effectively prevented by preprending a JavaScript syntax error to the start of the response.
268274

269275
Thus when delivering source maps over HTTP, servers may prepend a line starting with the string “)]}'” to the sourcemap. If the response starts with this string clients must ignore the first line.

0 commit comments

Comments
 (0)