fix: reset Kint CSP state in worker mode#10139
fix: reset Kint CSP state in worker mode#10139paulbalandan merged 1 commit intocodeigniter4:developfrom
Conversation
Signed-off-by: memleakd <121398829+memleakd@users.noreply.github.com>
|
Hi there, memleakd! 👋 Thank you for sending this PR! We expect the following in all Pull Requests (PRs).
Important We expect all code changes or bug-fixes to be accompanied by one or more tests added to our test suite to prove the code works. If pull requests do not comply with the above, they will likely be closed. Since we are a team of volunteers, we don't have any more time to work See https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/pull_request.md Sincerely, the mergeable bot 🤖 |
michalsn
left a comment
There was a problem hiding this comment.
Thank you for discovering, reporting, and fixing this. Truly the ideal situation.
Looks good to me.
Although for the 4.8 branch, we will need a small adjustment because CSP is lazy-loaded. I can take care of that later.
|
Thank you, @memleakd |
This fixes stale Kint renderer state in worker mode.
Kint stores CSP nonces and rich renderer pre-render state in static properties. In normal PHP execution those statics are discarded after each request, but in worker mode they persist across requests. This can cause Debug Toolbar/Kint inline assets to use stale CSP nonces and trigger browser CSP violations.
This change resets Kint's request-specific renderer state from
CodeIgniter::resetForWorkerMode()without reinitializing Kint or adding new public API.RichRenderer::$needs_pre_renderfor the next requestFixes #10138
Checklist: