Skip to content

fix: admin styling to a nonce'd <style> block (CSP is nonce-only) - #4

Merged
DanMat merged 1 commit into
mainfrom
fix/admin-csp-nonced-styles
Aug 30, 2026
Merged

DanMat merged 1 commit into
mainfrom
fix/admin-csp-nonced-styles

Conversation

@DanMat

@DanMat DanMat commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Companion to plugin-commerce#4. The admin CSP is nonce-only for style-src, so the inline style="" on the Inventory admin page (form-card flex, filter row, right-aligned numeric columns, heading spacing, drill-down margins) was dropped by the browser — multi-column forms collapsed and numbers weren't right-aligned on the live admin.

Fix

Emit one nonce-carrying <style> block per render (the handler already receives the CSP nonce) covering both the overview and the drill-down, and replace every inline style= with a class.

Tests

New guard: a <style nonce=…> block is emitted and no inline style= survives, on both the overview and the drill-down. 48 tests green; PHPStan + php-cs-fixer clean.

🤖 Generated with Claude Code

…e-only)

The admin CSP is nonce-only for style-src (no 'unsafe-inline'), so the inline
style="" attributes on the Inventory admin page (form-card flex layout, filter
row, right-aligned numeric columns, heading spacing, drill-down margins) were
being DROPPED by the browser — the multi-column forms collapsed and numbers
weren't right-aligned on the live admin.

Emit one nonce-carrying <style> block per render (the page handler already
receives the CSP nonce as its 2nd arg) covering both the overview and the
drill-down, and replace every inline style= with a class.

Tests: a new guard asserts a <style nonce=…> block is emitted and NO inline
style= attribute survives, on both the overview and the drill-down. 48 tests
green; PHPStan + php-cs-fixer clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@DanMat
DanMat merged commit eb50570 into main Aug 30, 2026
2 checks passed
@DanMat
DanMat deleted the fix/admin-csp-nonced-styles branch August 30, 2026 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant