Closed Bug 1642204 Opened 6 years ago Closed 3 years ago

cant use < or > in regex. string.replace(/>/g, '&gt;').replace(/</g, '&lt;'); breaks the script

Categories

(Core :: JavaScript Engine, defect)

73 Branch
defect

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: bob.t.allen, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0

Steps to reproduce:

string.replace(/>/g, '>').replace(/</g, '<'); breaks my script

Actual results:

It broke the script. works fine in chrome. Tried a bunch of things like escaping. It will work as a char replacement but replace only does the first one and I would need to write a silly while loop to get all of them just for this. The script is here: https://github.com/SuperIntuitive/SuperIntuitive/blob/master/editor/objects/scripter.js

Expected results:

it should replace the <> with < and > respectively.

the comment is rendered incorrectly because of bug 1642288.
here's correct "Steps to reproduce" and "Expected results".

Steps to reproduce:

string.replace(/>/g, '&gt;').replace(/</g, '&lt;'); breaks my script

Expected results:

it should replace the <> with &lt; and &gt; respectively.

Component: Untriaged → JavaScript Engine
Product: Firefox → Core

Do you mean that "<a></a>".replace(/>/g, '&gt;').replace(/</g, '&lt;') returns "&lt;a&gt;</a>" instead of "&lt;a&gt;&lt;/a&gt;" ?
if not, what do you mean by "break" ? what do you observe with the code?

Is there any live example that demonstrates the issue?

Flags: needinfo?(bob.t.allen)

bob.t.allen, thanks for taking the time to report this, but we need a little more information.

This code works correctly for me locally. If you can provide a link to a web page where it's broken, or tell how to set up Superintuitive so we can reproduce it locally, it would help a lot.

Any difference in behavior from Chrome on this sounds like it would be a bug that we would want to fix right away.

Setting to low severity for now, since we can't confirm the bug. If it's real, it's a big deal.

Severity: -- → S4

Reporter didn't answer NI, therefore resolving as INCOMPLETE.

Status: UNCONFIRMED → RESOLVED
Closed: 3 years ago
Resolution: --- → INCOMPLETE
Flags: needinfo?(bob.t.allen)
You need to log in before you can comment on or make changes to this bug.