GNU bug report logs - #7882
24.0.50; Bad regexp for javascript regexps

Previous Next

Package: emacs;

Reported by: Harald Hanche-Olsen <hanche <at> math.ntnu.no>

Date: Fri, 21 Jan 2011 17:43:02 UTC

Severity: normal

Found in version 24.0.50

Done: Stefan Monnier <monnier <at> IRO.UMontreal.CA>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 7882 in the body.
You can then email your comments to 7882 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7882; Package emacs. (Fri, 21 Jan 2011 17:43:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Harald Hanche-Olsen <hanche <at> math.ntnu.no>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 21 Jan 2011 17:43:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Harald Hanche-Olsen <hanche <at> math.ntnu.no>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.0.50; Bad regexp for javascript regexps
Date: Fri, 21 Jan 2011 18:50:29 +0100 (CET)
Put the following four line code snippet in a new buffer:

replace(/\\/g,something);
// Now we're in trouble:
// Still in trouble.
// And all's well again.

and activate js-mode and font-lock-mode.

The syntax colouring is now off: The code starting with the first
slash on the first line and ending with the first slash on the second
line is coloured as a regexp; now the syntax highlighter is unaware
that we are in a comment, and reads the single quote as the start of a
string. After the second single quote things return to normal.

The problem seems to lie with the constant js--regexp-literal declared
in js.el, as this regexp does not treat backslashes with sufficient care.

In GNU Emacs 24.0.50.1 (x86_64-apple-darwin10.5.0, NS apple-appkit-1038.35)
 of 2010-12-27 on mack
Windowing system distributor `Apple', version 10.3.1038
configured using `configure  '--with-ns''

- Harald




Reply sent to Stefan Monnier <monnier <at> IRO.UMontreal.CA>:
You have taken responsibility. (Fri, 21 Jan 2011 20:43:02 GMT) Full text and rfc822 format available.

Notification sent to Harald Hanche-Olsen <hanche <at> math.ntnu.no>:
bug acknowledged by developer. (Fri, 21 Jan 2011 20:43:02 GMT) Full text and rfc822 format available.

Message #10 received at 7882-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Harald Hanche-Olsen <hanche <at> math.ntnu.no>
Cc: 7882-done <at> debbugs.gnu.org
Subject: Re: bug#7882: 24.0.50; Bad regexp for javascript regexps
Date: Fri, 21 Jan 2011 15:50:17 -0500
> replace(/\\/g,something);

Thanks, I've installed the patch below into the emacs-23 branch which
should fix this problem.  The highlighting is not reliable when the
regexp spans multiple lines, tho, so I wonder: are multi-line regexps
valid? common? important?


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7882; Package emacs. (Fri, 21 Jan 2011 21:09:02 GMT) Full text and rfc822 format available.

Message #13 received at 7882 <at> debbugs.gnu.org (full text, mbox):

From: Harald Hanche-Olsen <hanche <at> math.ntnu.no>
To: 7882 <at> debbugs.gnu.org, help-debbugs <at> gnu.org
Subject: Re: bug#7882: closed
Date: Fri, 21 Jan 2011 22:16:28 +0100 (CET)
I have no idea how common or important multiline regexps are in
javascript. As far as I am concerned, if it's difficult to match them
reliably, maybe one shouldn't even try. Though that has its own
dangers: Namely, stuff inside an unmatched regexp triggering
inappropriate syntax highlighting. So perhaps we should stick with
doing the best we can, anyhow.

- Harald




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 19 Feb 2011 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 14 years and 125 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.