Skip to content

Trim whitespace at either end of a condition value - #62

Merged
sean-e-dietrich merged 1 commit into
mainfrom
fix/trim-condition-values
Oct 1, 2026
Merged

sean-e-dietrich merged 1 commit into
mainfrom
fix/trim-condition-values

Conversation

@sean-e-dietrich

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #61 (#60). Storing condition values as typed also stopped trimming them. Before #60, WordPress's sanitiser trimmed every value, so this restores that one piece of the old behaviour and keeps everything else #60 fixed.

Why trim: a space nobody can see is almost always pasted by accident, and it fails silently in the worst direction. A block rule on /wp-admin (starts_with, equals, ends_with) matches nothing, and nothing says so. That's a fail-open no Site Health check can catch.

Testing

  • New ConditionValueRoundTripTest::test_whitespace_at_either_end_is_trimmed:

    • through the screen: " /wp-admin \t " is stored as /wp-admin;
    • straight through the validator (the import and WP-CLI path): edge spaces are trimmed and a b is kept.
  • Unit: 326 tests pass.

  • Integration: 640 tests pass. The only warnings are the existing two about the local short DB_PASSWORD.

  • Static checks: composer lint and composer analyse are clean.

  • CHANGELOG: the Saving a rule strips < and percent-encodings from condition values #60 entry under [Unreleased] now says values are trimmed.

  • Was AI used in this pull request?

#60 stored condition values as typed, which stopped trimming them. A
space nobody can see is almost always pasted by accident, and it fails
silently in the worst direction: a block rule on "/wp-admin " matches
nothing. Trimmed in the validator, so the screen, an import and WP-CLI
all get it, as WordPress's sanitiser did before. Whitespace inside a
value is kept; a regex can still match a leading or trailing space.
@sean-e-dietrich
sean-e-dietrich merged commit ac5e3f7 into main Oct 1, 2026
14 checks passed
@sean-e-dietrich
sean-e-dietrich deleted the fix/trim-condition-values branch October 1, 2026 00:22
@sean-e-dietrich sean-e-dietrich mentioned this pull request Oct 1, 2026
1 task done
sean-e-dietrich added a commit that referenced this pull request Oct 1, 2026
Every stated version says 1.0.0-rc.6. [Unreleased] becomes [1.0.0-rc.6]
-- #59 (#52, #49), #61 (#60, #54) and #62 -- with a release-candidate lead
and a fresh [Unreleased] above it, and readme.txt's changelog gets a
matching entry.
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