Repository navigation
Description
Context
SimpleView::escape() uses htmlspecialchars( $value, ENT_COMPAT, 'UTF-8' ) (src/Infrastructure/View/SimpleView.php:282). ENT_COMPAT leaves single quotes unescaped, so an escaped value inside a single-quoted HTML attribute can break out of it.
View paths are not confined to an allowed root. SimpleView::validate() prefixes the plugin root and accepts .. segments (:179-186); TemplatedView::validate() falls back to any readable path it was given (src/Infrastructure/View/TemplatedView.php:70-84). Both then include the file (SimpleView.php:96-117). If a view name is ever derived from input, that is an arbitrary local-file include. The samples only use literal names, so this is hardening, not a live exploit.
Scope
- Escape with
ENT_QUOTES(and keep substituting invalid code units). - Resolve view paths to their canonical form and reject any path that leaves the allowed locations (the plugin root, plus the theme override locations) with
InvalidPath.
Out of scope
- Context-specific escaping helpers (attribute, URL, JavaScript); principle 9 expects templates to use WordPress's
esc_*functions for those. - Scoping theme overrides per plugin (tracked separately).
Acceptance criteria
- A value containing
'is escaped; a test fails before the change and passes after. - A view name containing
..that resolves outside the allowed locations throwsInvalidPath; tests forSimpleViewandTemplatedView. - Existing view tests still pass.
Verification
composer test
composer lintImpact on generated plugins
No: this does not change an interface or convention generated plugins rely on.
Activity
schlessera commentedon Oct 23, 2026
Picking this up on branch
fix/28-view-escaping-and-path-confinement. The citations in the body still matchorigin/main(5ab9ad1).