Last modified: 2014-05-24 22:23:15 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 42073 - "Search and replace" for IE does not correctly replace words but changes others
"Search and replace" for IE does not correctly replace words but changes others
Status: NEW
Product: MediaWiki extensions
Classification: Unclassified
WikiEditor (Other open bugs)
unspecified
All All
: High major (vote)
: ---
Assigned To: Nobody - You can work on this!
:
: 22878 23591 (view as bug list)
Depends on:
Blocks: 63665
  Show dependency treegraph
 
Reported: 2012-11-13 18:30 UTC by kipod
Modified: 2014-05-24 22:23 UTC (History)
6 users (show)

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


Attachments

Description kipod 2012-11-13 18:30:53 UTC
using the search and replace toolbar button in IE is broken.

REPLICATION
===========
* fire up IE
* open https://en.wikipedia.org/wiki/Software_bug?action=edit
* open "Advance" toolbar
* press the "search and replace" button
* enter "bug" for "search" and "bug" for "replace" (without the quotes)
* press "replace all"
* after the replace is complete, press "Show Changes"

WHAT YOU EXPECT
===============
nothing should change

WHAT YOU SEE
============
the page gets trashed.

problem exists when running legit replaces also, but replacing a string with itself makes it the most obvious.

peace.
Comment 1 Michael M. 2012-11-14 08:37:45 UTC
(In reply to comment #0)
> the page gets trashed.
= not "bug" is replaced with "bug", but the three letters before each "bug" are changed, and at the very beginning "bug" is inserted.
Comment 2 Andre Klapper 2012-11-14 11:48:54 UTC
Please mention the exact version of IE, and whether you have "compatibility mode" enabled or not. Bug 24194 might be related.
Comment 3 kipod 2012-11-14 14:12:37 UTC
did you try it?

for me it happens on IE 8 and 9, both with and without compatibility mode.

peace.
Comment 4 Andre Klapper 2012-11-14 14:41:08 UTC
(In reply to comment #3)
> did you try it?

I couldn't as I'd need a machine that IE runs on & there's no IE for Linux.

Thanks for sharing the IE versions here!
Comment 5 kipod 2012-11-14 19:14:01 UTC
i may be a complete dunce, but i can't understand this piece of code (could not find it in the repo - where is WikiEditor in the repo anyway? i had to cut it from the browser's debugger):

=== BIZARRE CODE BEGIN ===============
						} else if ( mode == 'replaceAll' ) {
							// Instead of using repetitive .match() calls, we use one .match() call with /g
							// and indexOf() followed by substr() to find the offsets. This is actually
							// faster because our indexOf+substr loop is faster than a match loop, and the
							// /g match is so ridiculously fast that it's negligible.
							// FIXME: Repetitively calling encapsulateSelection() is probably the best strategy
							// in Firefox/Webkit, but in IE replacing the entire content once is better.
							for ( i = 0; i < match.length; i++ ) {
								index = textRemainder.indexOf( match[i] );
								if ( index === -1 ) {
									// This shouldn't happen
									break;
								}
								var matchedText = textRemainder.substr( index, match[i].length );
								textRemainder = textRemainder.substr( index + match[i].length );

								start = index + offset;
								end = start + match[i].length;
								// Make regex placeholder substitution ($1) work
								var replace = isRegex ? matchedText.replace( regex, replaceStr ) : replaceStr;
								var newEnd = start + replace.length;
								$textarea
									.textSelection( 'setSelection', { 'start': start, 'end': end } )
									.textSelection( 'encapsulateSelection', {
											'peri': replace,
											'replace': true } )
									.textSelection( 'setSelection', { 'start': start, 'end': newEnd } );
								offset = newEnd;
							}
							$( '#wikieditor-toolbar-replace-success' )
								.text( mw.msg( 'wikieditor-toolbar-tool-replace-success', match.length ) )
								.show();
							$(this).data( 'offset', 0 );
						} else {
======= BIZARRE CODE END =============

this looks very strange. for the "ReplaceAll", all you have to do is
$textarea.val($textarea.val().replace(regex));
$( '#wikieditor-toolbar-replace-success' )
								.text( mw.msg( 'wikieditor-toolbar-tool-replace-success', match.length ) )
								.show();

using the "textSelection" tool for repetitive replacement, where in reality there *is* no selection, and the code iterate through loop of setting the selection and then using the selection tool with "replace" looks very perverted.

completely unrelated to this bug, but since i am here anyway: the most glaring omission of the "text and replace" tool is the ability to limit the "replace all" to current selection.

(i hate it that bugzilla does not have a "preview" feature).

peace.
Comment 6 kipod 2012-11-14 19:16:21 UTC
(In reply to comment #5)
> omission of the "text and replace" tool is the ability to limit the "replace
 
s/"text and replace"/"search and replace"/

(i hate it that bugzilla does not have a "preview" feature).
 
 peace.
Comment 7 kipod 2012-11-14 19:27:03 UTC
(In reply to comment #5)
> $textarea.val($textarea.val().replace(regex));

it seems that whoever wrote it chose to limit the interaction with $textarea to textSelection, but all it means is that this should be

$textara.textSelection( 'setContent', $textara.textSelection( 'getContent' ).replace( regex ));

or simply
$textara.textSelection( 'setContent', textRemainder.replace( regex ));

peace.
Comment 8 kipod 2012-11-14 22:00:56 UTC
my little snippet does not take isRegex into account.
it should really be:



$textarea.val($textarea.val().replace(regex,
function(matchStr) { return isRegex ? matchedStr.replace( regex, replaceStr ) : replaceStr; } ));


peace.
Comment 9 Andre Klapper 2012-11-15 08:52:05 UTC
(In reply to comment #6)
> (i hate it that bugzilla does not have a "preview" feature).

File your upstream request in bugzilla.mozilla.org, and paste longer code in attachments... Thanks.
Comment 10 kipod 2012-11-16 16:02:18 UTC
(In reply to comment #9)
> (In reply to comment #6)
> > (i hate it that bugzilla does not have a "preview" feature).
> 
> File your upstream request in bugzilla.mozilla.org, 

ahhh.... one of the oldest in the book:
https://bugzilla.mozilla.org/show_bug.cgi?id=40896
(circa 2000).



> ... and paste longer code in attachments... Thanks.
will do.


peace.
Comment 11 kipod 2012-11-28 00:29:54 UTC
verified that problem still exists on wmf5.

peace.
Comment 12 Andre Klapper 2013-03-20 14:44:42 UTC
*** Bug 23591 has been marked as a duplicate of this bug. ***
Comment 13 Andre Klapper 2013-03-20 14:44:54 UTC
*** Bug 22878 has been marked as a duplicate of this bug. ***
Comment 14 XP1 2013-05-17 09:21:01 UTC
See:

Bug 23992 - Search&replace disabled in IE8, Opera:
https://bugzilla.wikimedia.org/show_bug.cgi?id=23992

Bug 48305 - 1.22wmf3, "Search and replace" capability not working in IE/Opera:
https://bugzilla.wikimedia.org/show_bug.cgi?id=48305

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


Navigation
Links