Repository navigation
Treat an empty search text as a space in #pos, #rpos, #replace and #explode - #65
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MediaWiki's ParserFunctions search for a single space when the search text of
#pos,#rpos,#replaceor#explodeis 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. , ) at the edge of an#if,#ifeq,#switch,#ifexpror#iferrorresult, 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).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|| }}]givesa b cwith non-breaking spaces.Investigated and written by Claude on behalf of William Jacoby (bonelifer).
🤖 Generated with Claude Code