Closed Bug 1350575 Opened 8 years ago Closed 8 years ago

RegExp constructor doesn't preserve newlines in source

Categories

(DevTools :: Console, defect)

55 Branch
defect
Not set
normal

Tracking

(firefox52 unaffected, firefox53 unaffected, firefox54 unaffected)

RESOLVED INVALID
Tracking Status
firefox52 --- unaffected
firefox53 --- unaffected
firefox54 --- unaffected

People

(Reporter: 1212jtraceur, Unassigned)

References

Details

(Keywords: regression)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36 Steps to reproduce: In the JS console on a Nightly build (55.0a1 (2017-03-25) (64-bit)), run the following: RegExp('\n').source Actual results: The string source of this regex contains the literal characters \ and n (codes 92 and 110). Expected results: The regex source should contain only a single linefeed character. See here for more details/context: https://github.com/slevithan/xregexp/pull/163#issuecomment-288633467 > This seems to be a quirk in Firefox (not certain it's technically a bug). > What's happening is that when the string pattern is converted into a regex, > Firefox is changing the string '\n' (LF, char code 10) to the regex pattern /\n/, > which seems inappropriate to me even if it's not technically a bug (not > sure what the spec might have to say about this edge case which only matters > when looking at the string source of the resulting regex). The string source > of this regex now contains the literal characters \ and n (codes 92 and 110), > rather than LF. :-/
Component: Untriaged → JavaScript Engine
Product: Firefox → Core
Blocks: 1342526
Status: UNCONFIRMED → NEW
Has Regression Range: --- → yes
Has STR: --- → yes
Component: JavaScript Engine → Developer Tools: Console
Ever confirmed: true
Flags: needinfo?(ttromey)
Keywords: regression
Product: Core → Firefox
On second thought, it seems I was mistaken on this one, after reading through https://github.com/kangax/compat-table/issues/798 and the linked resources.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → INVALID
Adjusting flags based on the resolution of the bug.
Clearing the NI.
Flags: needinfo?(ttromey)
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.