Repository navigation
fix: escape the error text in the PHP info panel (#117) - #118
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #117
Problem
capturePhpInfo()inphp-worker.jsreturned<pre>${formatErrorDetail(error)}</pre>unescaped; the shell loads it into#phpinfo-frameviasrcdoc, so<and&in the error text were parsed as markup. The worker'sbuildLoadingResponse()and the service worker'sbuildErrorResponse()interpolatedformatErrorDetail()output the same way into pages served to the app frame.Solution
formatErrorHtml(error)andescapeHtml(text)insrc/shared/protocol.js; the worker useshtml: formatErrorHtml(error).buildLoadingResponse()(worker) escapes its message with the sharedescapeHtml;buildErrorResponse()(sw) uses theescapeHtmlalready defined insw.js.Mirrors erseco/facturascripts-playground#174, extended to the two error pages found by grepping for
<pre>${.Tests
formatErrorHtml escapes the error textintests/shared-protocol.test.mjs: red with the unescaped wrapper (<pre>Error: <img src=x onerror="alert(1)"> & more</pre>), green after the fix. Plus anescapeHtmlcase.npm test: 236/236 pass.make lintclean.npm run build-workerrebuilt; both bundles escape the message.