If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

String.replace, alert is broken in somecase

RESOLVED INVALID

Status

()

Firefox
General
--
major
RESOLVED INVALID
12 years ago
12 years ago

People

(Reporter: ylsdd, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

12 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051025 Firefox/1.5
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051025 Firefox/1.5

I'm using a function html2ansi(str) to replace some strings in str. The parameter 'str' came from the content of a editable iframe. But when the content of this iframe is copied from Mozilla (either 1.0.7 or 1.5 rc1) it self, 

         str.replace(/\n/gi, '')

will replace some blanks to ''. If it was copied from a IE window, str.replace just decrease the lenght of str a little.

I modified the program to the following, but the problem is still there,

function html2ansi(str)
{
(1)   alert('length: '+ str.length + ' '+ str);
      str=str.replace(/\n/gi, '<tmpstring>');
      str=str.replace(/<tmpstring>/, '');
(2)   alert('length: '+ str.length + ' '+ str);
      ...
(3)   alert(str);
      return str;
}

The line (1) gives,

length: 144 The days of a program living as a single entity are all but gone. Today's programs need to be more versatile and expandable. The simpest way to 

The line (2) gives the following. VERY WIRED. At line (2) there is actually
no '<tmpsting>' in str, but '<tmpstring>' is displayed in 'alert'.

length: 153 The days of a program living as a single entity are all but gone. Today's programs need to be more versatile and expandable. The simpest<tmpstring>way to 

At line (3), alert still gives '....<tmpstring>...', but in the returned value,
there is actually no '<tmpstring>'.

I can not make a single html file to repeat this yet. But it happens every time
on my website (a Chinese website, GB2312, not English). If you want to look at it, send me a email (yasheng@gmail.com) for a step by step instruction.




Reproducible: Always
(Reporter)

Comment 1

12 years ago
I write a example page on

       http://tttan.com/strreplace.html

which repeats this bug everytime.
(Reporter)

Comment 2

12 years ago
Hint... the lost spaces were just at the line breaks of the alert window before
the replacement. Even if the 'alert()' is removed, you lose the same spaces.
(Reporter)

Comment 3

12 years ago
Ok, I got it. Firefox generated some unwanted line breaks.

(In reply to comment #2)
> Hint... the lost spaces were just at the line breaks of the alert window before
> the replacement. Even if the 'alert()' is removed, you lose the same spaces.
> 

Status: UNCONFIRMED → RESOLVED
Last Resolved: 12 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.