Skip to content

Pattern directory: tidy output escaping and query handling - #766

Merged
obenland merged 3 commits into
trunkfrom
pattern-directory/tidy-escaping-and-query
Aug 31, 2026
Merged

Pattern directory: tidy output escaping and query handling#766
obenland merged 3 commits into
trunkfrom
pattern-directory/tidy-escaping-and-query

Conversation

@obenland

Copy link
Copy Markdown
Member

A small consistency pass across the pattern directory plugin and the 2024 theme. No behavior changes for normal use — mostly making output escaping and a couple of query paths match the conventions used elsewhere in the codebase.

Changes

Output escaping (context-appropriate helpers)

  • Admin flag row actions and pattern row actions now use esc_url() for link hrefs (were esc_attr() or unescaped).
  • Theme link shortcodes (pattern_edit_link, pattern_draft_link) return esc_url()'d URLs.
  • report-pattern block: term name printed as content uses esc_html().
  • pattern-preview frame: iframe title attribute uses esc_attr_e().
  • status-notice block: unlisted reason runs through wp_kses_post(), matching the equivalent REST field.
  • Archive title block: title output uses esc_html() and the heading tag is constrained to h1h6.

Query handling

  • Pending-flags query: orderby/order normalized to known columns and ASC/DESC.
  • Pattern REST query: the allowed_blocks filter is limited to well-formed block names before it's used.

Translations

  • BasicText parser aligns its replacement handling with the Heading/Paragraph parsers.

Notes

  • phpcs passes clean (0 errors / 0 warnings) on all changed files; php -l clean.
  • The report-pattern and pattern-preview render.php files are served from build/, so a npm run build:theme is needed for those two to take effect at runtime.

Small consistency pass across the directory plugin and theme:

- Use context-appropriate escaping helpers (esc_url/esc_html/esc_attr) for
  link, content, and attribute output in the admin flag/pattern row actions,
  theme shortcodes, and a couple of block templates.
- Normalize the pending-flags query ordering to known columns and directions.
- Constrain the pattern REST query's block filter to well-formed block names.
- Align the basic-text translation parser's replacement handling with the
  heading and paragraph parsers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 31, 2026 15:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

…rowing

- Align the allowed_blocks validation with WordPress's block-name grammar
  (^[a-z0-9-]+/[a-z0-9-]+$) so names starting with a digit or hyphen aren't
  dropped.
- Keep building the meta_query when the parameter was supplied, so a list that
  filters down to nothing narrows results instead of returning everything.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@obenland
obenland force-pushed the pattern-directory/tidy-escaping-and-query branch from f320c8e to 3f724f3 Compare August 31, 2026 15:53
…ases

- allowed_blocks: when every supplied name is invalid, match no patterns
  explicitly instead of emitting a degenerate '^((),?)+$' regex (which would
  match empty-meta rows and can error on older regex engines).
- Pending-flags query: guard orderby/order against non-string (array) values
  so multi-column sort input can't trigger a string-conversion warning.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@obenland
obenland merged commit 17bd5d6 into trunk Aug 31, 2026
3 checks passed
@obenland
obenland deleted the pattern-directory/tidy-escaping-and-query branch August 31, 2026 16:09
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.

2 participants