File tree Expand file tree Collapse file tree 6 files changed +16
-23
lines changed
apps/svelte.dev/src/routes Expand file tree Collapse file tree 6 files changed +16
-23
lines changed Original file line number Diff line number Diff line change 8
8
import { mapbox_setup } from ' ../../../../config.js' ;
9
9
import AppControls from ' ./AppControls.svelte' ;
10
10
import { compress_and_encode_text , decode_and_decompress_text } from ' ./gzip.js' ;
11
+ import { page } from ' $app/stores' ;
11
12
12
13
let { data } = $props ();
13
14
18
19
let version = data .version ;
19
20
let setting_hash: any = null ;
20
21
22
+ // Hashed URLs are less safe (we can't delete malicious REPLs), therefore
23
+ // don't allow links to escape the sandbox restrictions
24
+ const can_escape = browser && ! $page .url .hash ;
25
+
21
26
onMount (() => {
22
27
if (version !== ' local' ) {
23
28
fetch (` https://unpkg.com/svelte@${version }/package.json ` )
127
132
bind:this ={repl }
128
133
{svelteUrl }
129
134
{relaxed }
135
+ {can_escape }
130
136
vim ={data .vim }
131
137
injectedJS ={mapbox_setup }
132
138
showModified
Original file line number Diff line number Diff line change 50
50
bind:this ={repl }
51
51
{svelteUrl }
52
52
{relaxed }
53
+ can _escape
53
54
injectedJS ={mapbox_setup }
54
55
showModified
55
56
showAst
Original file line number Diff line number Diff line change 34
34
{#if browser }
35
35
<Viewer
36
36
relaxed
37
+ can _escape
37
38
onLog ={(l : Log []) => logs = l }
38
39
{bundle }
39
40
theme ={$theme .current }
Original file line number Diff line number Diff line change 13
13
export let runtimeError: Error | null = null ;
14
14
export let embedded = false ;
15
15
export let relaxed = false ;
16
+ export let can_escape = false ;
16
17
export let injectedJS: string ;
17
18
export let injectedCSS: string ;
18
19
export let showAst = false ;
61
62
bind:error ={runtimeError }
62
63
{status }
63
64
{relaxed }
65
+ {can_escape }
64
66
{injectedJS }
65
67
{injectedCSS }
66
68
theme ={previewTheme }
Original file line number Diff line number Diff line change 18
18
export let status: string | null ;
19
19
/** sandbox allow-same-origin */
20
20
export let relaxed = false ;
21
+ /** sandbox allow-popups-to-escape-sandbox (i.e. links within the REPL to other pages work) */
22
+ export let can_escape = false ;
21
23
/** Any additional JS you may want to inject */
22
24
export let injectedJS = ' ' ;
23
25
/** Any additional CSS you may want to inject */
247
249
class:inited
248
250
bind:this ={iframe }
249
251
sandbox ={[
250
- ' allow-popups-to-escape-sandbox' ,
251
252
' allow-scripts' ,
252
253
' allow-popups' ,
253
254
' allow-forms' ,
254
255
' allow-pointer-lock' ,
255
- ' allow-top-navigation' ,
256
256
' allow-modals' ,
257
+ can_escape ? ' allow-popups-to-escape-sandbox' : ' ' ,
257
258
relaxed ? ' allow-same-origin' : ' '
258
259
].join (' ' )}
259
260
class ={error || pending || pending_imports ? ' greyed-out' : ' ' }
269
270
{#if ! onLog }
270
271
<PaneWithPanel pos =" 90%" panel =" Console" >
271
272
<div slot =" main" >
272
- <iframe
273
- title =" Result"
274
- class:inited
275
- bind:this ={iframe }
276
- sandbox ={[
277
- ' allow-popups-to-escape-sandbox' ,
278
- ' allow-scripts' ,
279
- ' allow-popups' ,
280
- ' allow-forms' ,
281
- ' allow-pointer-lock' ,
282
- ' allow-top-navigation' ,
283
- ' allow-modals' ,
284
- relaxed ? ' allow-same-origin' : ' '
285
- ].join (' ' )}
286
- class ={error || pending || pending_imports ? ' greyed-out' : ' ' }
287
- srcdoc ={BROWSER ? srcdoc : ' ' }
288
- ></iframe >
289
-
290
- {#if $bundle ?.error }
291
- <ErrorOverlay error ={$bundle .error } />
292
- {/if }
273
+ {@render main ()}
293
274
</div >
294
275
295
276
<div slot =" panel-header" >
Original file line number Diff line number Diff line change 20
20
export let embedded = false ;
21
21
export let orientation: ' columns' | ' rows' = ' columns' ;
22
22
export let relaxed = false ;
23
+ export let can_escape = false ;
23
24
export let fixed = false ;
24
25
export let fixedPos = 50 ;
25
26
export let injectedJS = ' ' ;
312
313
status ={status_visible ? status : null }
313
314
{embedded }
314
315
{relaxed }
316
+ {can_escape }
315
317
{injectedJS }
316
318
{injectedCSS }
317
319
{showAst }
You can’t perform that action at this time.
0 commit comments