Release v0.51.278 — Release IT (stage-p3g — repair inline PDF preview #3652) - #3684
Conversation
…n CSP test window
|
| Filename | Overview |
|---|---|
| static/ui.js | Fixes the PDF.js loader by switching from a src+textContent script element (textContent ignored per spec) to a blob module script; also passes isEvalSupported:false. The blob URL is revoked on load but not on error. |
| api/helpers.py | Adds blob: to script-src and a new worker-src directive to support the PDF.js blob module script; script-src already had 'unsafe-inline' so the blob: addition is a marginal relaxation in practice. |
| tests/test_pwa_manifest_csp.py | Widens the CSP substring capture window from 600 to 1000 chars to accommodate the new blob:/worker-src directives; the window approach remains fragile but was pre-existing. |
| CHANGELOG.md | Adds release notes for v0.51.278 describing the PDF.js loader fix and CSP changes; no code concerns. |
Sequence Diagram
sequenceDiagram
participant Page as Browser Page
participant Blob as Blob URL module
participant CDN as cdn.jsdelivr.net
participant Worker as PDF.js Worker
Page->>Page: URL.createObjectURL(blob script)
Page->>Blob: "script type=module src=blobUrl"
Blob->>CDN: import pdf.min.mjs
CDN-->>Blob: PDF.js module
Blob->>Blob: set GlobalWorkerOptions.workerSrc
Blob->>Page: window._pdfjsLib assigned, dispatch pdfjs-ready
Page->>Page: URL.revokeObjectURL on onload
Page->>CDN: getDocument with isEvalSupported false
CDN-->>Worker: spawn pdf.worker.min.mjs
Worker-->>Page: PDF pages rendered
Reviews (1): Last reviewed commit: "docs(changelog): v0.51.278 — Release IT ..." | Re-trigger Greptile
| `; | ||
| const _pdfBlobUrl=URL.createObjectURL(_pdfBlob); | ||
| s.src=_pdfBlobUrl; | ||
| s.onload=()=>URL.revokeObjectURL(_pdfBlobUrl); |
There was a problem hiding this comment.
Missing
onerror handler leaks the blob URL on load failure
If the blob module script fails to load (e.g., the CDN is unreachable, a browser rejects blob: in script-src, or the import of PDF.js itself throws), onload never fires and _pdfBlobUrl is never passed to URL.revokeObjectURL. The blob stays alive in the page's origin until navigation. The user also waits the full 15-second timeout before the download fallback appears, whereas an onerror handler could degrade immediately. The PR description already notes this as a follow-up; surfacing it here so it gets tracked.
…esquena#3652) (nesquena#3684) * fix(ui): repair inline PDF preview (blob module loader + CSP worker-src) (nesquena#3652, nesquena#3649) Co-authored-by: sky <example@email.com> * docs(changelog): v0.51.278 — Release IT (stage-p3g, nesquena#3652 only); widen CSP test window --------- Co-authored-by: nesquena-hermes <[email protected]> Co-authored-by: sky <example@email.com>
Release v0.51.278 — Release IT (stage-p3g)
Phase-3-MEDIUM — #3652 (xx77yy; closes #3649). #3654 (self-update reload race) was dropped from this stage and re-held — its uptime-
<readiness gate has a core design flaw (a fresh old process makes the comparison never trip → reload hangs); needs a backend/healthboot-id change the contributor should own (full repro + fix direction left on #3654).Fixed
<script>with bothsrcandtextContent(textContent ignored when src present), so PDF.js never initialized. Now loads via a blob module script that setsworkerSrc, passesisEvalSupported:false, and revokes the blob URL on load. CSP gainsblob:inscript-src+ a scopedworker-src blob: 'self' https://cdn.jsdelivr.net. (Nathan approved theblob:CSP relaxation.)Gates
node -c+ast.parseclean, ruff CLEAN, ESLint runtime CLEAN, browser smoke CLEAN'unsafe-eval'not introduced). Non-blocking follow-ups noted: adds.onerrorrevoke for symmetry; add a test pinning'unsafe-eval'absence.Closes #3652. Includes a test update widening
test_pwa_manifest_csp's CSP capture window (the new directives pushedform-actionpast the old 600-char window).