Skip to content

Treat an empty search text as a space in #pos, #rpos, #replace and #explode - #65

Merged
bonelifer merged 1 commit into
mainfrom
fix-empty-search-is-space
Oct 14, 2026
Merged

bonelifer merged 1 commit into
mainfrom
fix-empty-search-is-space

Conversation

@bonelifer

Copy link
Copy Markdown
Contributor

MediaWiki's ParserFunctions search for a single space when the search text of #pos, #rpos, #replace or #explode is empty. Arguments are trimmed, so this is the only way to search for a space, and Nowrap-style templates rely on it: {{#replace: text ||  }}. The wiki returned the text unchanged (#replace) or nothing (#pos, #rpos, #explode).

Changes:

  • text_tools: an empty search text or separator is a single space.
  • Tests for that, and tests that an entity space ( , 
) at the edge of an #if, #ifeq, #switch, #ifexpr or #iferror result, or of a named template parameter, survives the trim. It already did on a board; a reported bug about it came from a test tool decoding entities twice (fixed in phpbbmodders/wiki-templates).
  • README: the function table mentions the empty search text.

Claude ran the unit tests on phpBB 3.3.x and master (277 tests pass; the 3 migration tests that are skipped on master were skipped before this change). Claude also checked the change on a seed-forum test board through the edit form's preview: [{{#replace:a b c|| }}] gives a b c with non-breaking spaces.


Investigated and written by Claude on behalf of William Jacoby (bonelifer).

🤖 Generated with Claude Code

…xplode

MediaWiki's ParserFunctions search for a single space when the search
text is empty. Arguments are trimmed, so that is the only way to search
for a space, and templates such as Nowrap rely on it with
{{#replace: text ||  }}. The wiki returned the text unchanged
(#replace) or nothing (#pos, #rpos, #explode) instead.

Also adds tests that an entity space ( , 
) at the edge of an
#if, #ifeq, #switch, #ifexpr or #iferror result, or of a named template
parameter, survives the trim, as it already does on a board.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bonelifer
bonelifer merged commit bba6376 into main Oct 14, 2026
58 checks passed
@bonelifer
bonelifer deleted the fix-empty-search-is-space branch October 14, 2026 21:47
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