Commit b5d9a12
authored
fix(web): break redirect-loop scripts that freeze the HTML preview (#5469)
* fix(web): break redirect-loop scripts that freeze the HTML preview
A generated or hand-edited artifact carrying a self-redirecting directive
β most reliably a `<meta http-equiv="refresh">` that reloads the same
document, or a cycle of meta refreshes (A -> B -> A -> ...) β reloads the
preview iframe forever and pegs the main thread until the whole design
workspace freezes. There was no loop detection or hop limit, so the
preview stayed unusable.
Add an in-iframe circuit breaker (`injectPreviewRedirectGuard`, always
injected by `buildSrcdoc`) that counts meta-refresh hops in `window.name`
β the one store that survives an iframe navigating itself β resets the
count once a full window elapses with no further refresh (timeout
safeguard so a slow legitimate auto-refresh never accumulates), and once
the hop budget is exceeded, or immediately for a near-instant
self-refresh, strips the offending `<meta>`, stops the frame, and posts
`od:redirect-loop-blocked` to the host. The host parks the srcDoc iframe
on a static "loop detected" placeholder, the reliable stop the browser's
unforgeable `window.location` otherwise denies.
Route any self-redirecting source onto the srcDoc path
(`htmlNeedsRedirectGuard`) so the guard is always present instead of the
URL-load path serving the document raw and unguarded.
Covered by a runtime spec that runs the real injected guard through a VM
modelling a sandboxed iframe reloading itself (hop budget, window reset,
immediate self-refresh kill, chain-break, host message) plus render-mode
detection specs.
Source: https://plane.powerformer.net/open-design/projects/49832a02-3158-4faf-bf2f-d0e39c40c7e6/issues/94709b20-f403-4ed7-a960-1e26572fa394
Generated-By: looper 0.0.0-dev (runner=worker, agent=claude-code)
* fix(web): cover srcdoc redirect guard gaps
* fix(web): avoid redirect guard false positives1 parent be98224 commit b5d9a12
5 files changed
Lines changed: 739 additions & 3 deletions
File tree
- apps/web
- src
- components
- runtime
- tests
- components
- runtime
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
121 | 127 | | |
122 | 128 | | |
123 | 129 | | |
| |||
135 | 141 | | |
136 | 142 | | |
137 | 143 | | |
| 144 | + | |
138 | 145 | | |
139 | 146 | | |
140 | 147 | | |
| |||
7058 | 7065 | | |
7059 | 7066 | | |
7060 | 7067 | | |
| 7068 | + | |
| 7069 | + | |
| 7070 | + | |
| 7071 | + | |
| 7072 | + | |
| 7073 | + | |
| 7074 | + | |
| 7075 | + | |
| 7076 | + | |
| 7077 | + | |
| 7078 | + | |
| 7079 | + | |
| 7080 | + | |
7061 | 7081 | | |
7062 | 7082 | | |
7063 | 7083 | | |
| |||
7106 | 7126 | | |
7107 | 7127 | | |
7108 | 7128 | | |
| 7129 | + | |
7109 | 7130 | | |
7110 | 7131 | | |
7111 | 7132 | | |
| |||
7184 | 7205 | | |
7185 | 7206 | | |
7186 | 7207 | | |
| 7208 | + | |
| 7209 | + | |
| 7210 | + | |
| 7211 | + | |
| 7212 | + | |
| 7213 | + | |
| 7214 | + | |
| 7215 | + | |
| 7216 | + | |
| 7217 | + | |
| 7218 | + | |
| 7219 | + | |
| 7220 | + | |
| 7221 | + | |
| 7222 | + | |
| 7223 | + | |
| 7224 | + | |
| 7225 | + | |
| 7226 | + | |
| 7227 | + | |
| 7228 | + | |
| 7229 | + | |
7187 | 7230 | | |
7188 | 7231 | | |
7189 | 7232 | | |
| |||
7414 | 7457 | | |
7415 | 7458 | | |
7416 | 7459 | | |
7417 | | - | |
| 7460 | + | |
| 7461 | + | |
| 7462 | + | |
| 7463 | + | |
| 7464 | + | |
| 7465 | + | |
| 7466 | + | |
| 7467 | + | |
| 7468 | + | |
| 7469 | + | |
7418 | 7470 | | |
7419 | 7471 | | |
7420 | 7472 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
67 | 75 | | |
68 | 76 | | |
69 | 77 | | |
| |||
105 | 113 | | |
106 | 114 | | |
107 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
108 | 120 | | |
109 | 121 | | |
110 | 122 | | |
| |||
257 | 269 | | |
258 | 270 | | |
259 | 271 | | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
0 commit comments