Skip to content

fix: escape the error text in the PHP info panel (#117) - #118

Merged
erseco merged 1 commit into
mainfrom
hotfix/issue-117-escape-phpinfo-error
Oct 19, 2026
Merged

erseco merged 1 commit into
mainfrom
hotfix/issue-117-escape-phpinfo-error

Conversation

@erseco

@erseco erseco commented Oct 19, 2026

Copy link
Copy Markdown
Member

Closes #117

Problem

capturePhpInfo() in php-worker.js returned <pre>${formatErrorDetail(error)}</pre> unescaped; the shell loads it into #phpinfo-frame via srcdoc, so < and & in the error text were parsed as markup. The worker's buildLoadingResponse() and the service worker's buildErrorResponse() interpolated formatErrorDetail() output the same way into pages served to the app frame.

Solution

  • formatErrorHtml(error) and escapeHtml(text) in src/shared/protocol.js; the worker uses html: formatErrorHtml(error).
  • buildLoadingResponse() (worker) escapes its message with the shared escapeHtml; buildErrorResponse() (sw) uses the escapeHtml already defined in sw.js.

Mirrors erseco/facturascripts-playground#174, extended to the two error pages found by grepping for <pre>${.

Tests

  • formatErrorHtml escapes the error text in tests/shared-protocol.test.mjs: red with the unescaped wrapper (<pre>Error: <img src=x onerror="alert(1)"> & more</pre>), green after the fix. Plus an escapeHtml case.
  • npm test: 236/236 pass. make lint clean. npm run build-worker rebuilt; both bundles escape the message.

capturePhpInfo() interpolated the error into the panel HTML as is, so
"<" and "&" in PHP output, paths or blueprint values were parsed as
markup. formatErrorHtml() in src/shared/protocol.js escapes the text
before wrapping it in <pre>. The worker's loading/error page and the
service worker's error page now escape their message too.

Closes #117
@erseco erseco added the bug Something isn't working label Oct 19, 2026
@erseco erseco self-assigned this Oct 19, 2026
@erseco
erseco merged commit 35d5db6 into main Oct 19, 2026
6 checks passed
@erseco
erseco deleted the hotfix/issue-117-escape-phpinfo-error branch October 19, 2026 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error text is not escaped in the PHP info panel and error pages

1 participant