Last modified: 2014-04-08 08:59:34 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T58228, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 56228 - "replace all" does not work with a regular expression that contains a caret or a dollar
"replace all" does not work with a regular expression that contains a caret o...
Status: NEW
Product: MediaWiki extensions
Classification: Unclassified
WikiEditor (Other open bugs)
unspecified
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks: 63665
  Show dependency treegraph
 
Reported: 2013-10-27 23:05 UTC by orlodrim
Modified: 2014-04-08 08:59 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description orlodrim 2013-10-27 23:05:24 UTC
Hello,

The algorithm for "replace all" in WikiEditor, as described in a comment in modules/jquery.wikiEditor.dialogs.config.js, is the following: "Instead of using repetitive .match() calls, we use one .match() call with /g and indexOf() followed by substr() to find the offsets."

In general, this does not work when regular expression mode is turned on and the regular expression contains "^" or "$", because calling indexOf on the matched text ignores the constraint that this text must be at the beginning/end of a line.

Example:
* Open a page in edit mode and set the text of the edit box to "aa"
* Open the search and replace dialog of WikiEditor.
* Set "search for" to "a$"
* Set "replace with" to "b"
* Enable "Treat search string as a regular expression"
* Click "Replace all"

Expected result: "ab"
Real result: "ba"
What happens: the content of the only match is "a", and the first occurrence of "a" in "aa" is at position 0.
Comment 1 Andre Klapper 2013-10-28 15:31:42 UTC
Thanks for taking the time to report this and the great analysis!

Would you interested in providing a patch to fix the problem? See https://www.mediawiki.org/wiki/Developer_access and https://www.mediawiki.org/wiki/Gerrit/Tutorialfor more information.
Comment 2 orlodrim 2013-11-03 11:17:24 UTC
Sorry, for personal reasons, I don't want to contribute directly to MediaWiki source code at the moment.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links