From unknown Tue Aug 19 02:51:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7882: 24.0.50; Bad regexp for javascript regexps Resent-From: Harald Hanche-Olsen Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 21 Jan 2011 17:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 7882 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 7882@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.129563177625186 (code B ref -1); Fri, 21 Jan 2011 17:43:02 +0000 Received: (at submit) by debbugs.gnu.org; 21 Jan 2011 17:42:56 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgL0h-0006YB-De for submit@debbugs.gnu.org; Fri, 21 Jan 2011 12:42:55 -0500 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgL0f-0006Xy-7W for submit@debbugs.gnu.org; Fri, 21 Jan 2011 12:42:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PgL8I-0003PJ-Tv for submit@debbugs.gnu.org; Fri, 21 Jan 2011 12:50:47 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:47065) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PgL8I-0003P0-DE for submit@debbugs.gnu.org; Fri, 21 Jan 2011 12:50:46 -0500 Received: from [140.186.70.92] (port=49743 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PgL8D-0001uM-Op for bug-gnu-emacs@gnu.org; Fri, 21 Jan 2011 12:50:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PgL88-0003O6-78 for bug-gnu-emacs@gnu.org; Fri, 21 Jan 2011 12:50:38 -0500 Received: from anne.math.ntnu.no ([129.241.15.150]:55370) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1PgL87-0003EN-PH for bug-gnu-emacs@gnu.org; Fri, 21 Jan 2011 12:50:36 -0500 Received: (qmail 7630 invoked from network); 21 Jan 2011 17:50:30 -0000 Received: from gauss.math.ntnu.no (HELO localhost) (hanche@129.241.15.102) by anne.math.ntnu.no with ESMTPA; 21 Jan 2011 17:50:30 -0000 Date: Fri, 21 Jan 2011 18:50:29 +0100 (CET) Message-Id: <20110121.185029.1304555966254424651.hanche@math.ntnu.no> From: Harald Hanche-Olsen X-URL: http://www.math.ntnu.no/~hanche/ X-Mailer: Mew version 6.3.50 on Emacs 24.0.50 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Spam-Score: -6.1 (------) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.1 (------) 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 From unknown Tue Aug 19 02:51:46 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.427 (Entity 5.427) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Harald Hanche-Olsen Subject: bug#7882: closed (Re: bug#7882: 24.0.50; Bad regexp for javascript regexps) Message-ID: References: <20110121.185029.1304555966254424651.hanche@math.ntnu.no> X-Gnu-PR-Message: they-closed 7882 X-Gnu-PR-Package: emacs Reply-To: 7882@debbugs.gnu.org Date: Fri, 21 Jan 2011 20:43:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1295642582-10601-1" This is a multi-part message in MIME format... ------------=_1295642582-10601-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #7882: 24.0.50; Bad regexp for javascript regexps which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 7882@debbugs.gnu.org. --=20 7882: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D7882 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1295642582-10601-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 7882-done) by debbugs.gnu.org; 21 Jan 2011 20:42:30 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgNoU-0002kJ-Cf for submit@debbugs.gnu.org; Fri, 21 Jan 2011 15:42:30 -0500 Received: from chene.dit.umontreal.ca ([132.204.246.20]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgNoO-0002jz-Kx for 7882-done@debbugs.gnu.org; Fri, 21 Jan 2011 15:42:28 -0500 Received: from faina.iro.umontreal.ca (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id p0LKofuR012437; Fri, 21 Jan 2011 15:50:41 -0500 Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id 47BB7B411E; Fri, 21 Jan 2011 15:50:17 -0500 (EST) From: Stefan Monnier To: Harald Hanche-Olsen Subject: Re: bug#7882: 24.0.50; Bad regexp for javascript regexps Message-ID: References: <20110121.185029.1304555966254424651.hanche@math.ntnu.no> Date: Fri, 21 Jan 2011 15:50:17 -0500 In-Reply-To: <20110121.185029.1304555966254424651.hanche@math.ntnu.no> (Harald Hanche-Olsen's message of "Fri, 21 Jan 2011 18:50:29 +0100 (CET)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV3735=0 X-Spam-Score: -2.0 (--) X-Debbugs-Envelope-To: 7882-done Cc: 7882-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.0 (--) > 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 ------------=_1295642582-10601-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 21 Jan 2011 17:42:56 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgL0h-0006YB-De for submit@debbugs.gnu.org; Fri, 21 Jan 2011 12:42:55 -0500 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgL0f-0006Xy-7W for submit@debbugs.gnu.org; Fri, 21 Jan 2011 12:42:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PgL8I-0003PJ-Tv for submit@debbugs.gnu.org; Fri, 21 Jan 2011 12:50:47 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:47065) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PgL8I-0003P0-DE for submit@debbugs.gnu.org; Fri, 21 Jan 2011 12:50:46 -0500 Received: from [140.186.70.92] (port=49743 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PgL8D-0001uM-Op for bug-gnu-emacs@gnu.org; Fri, 21 Jan 2011 12:50:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PgL88-0003O6-78 for bug-gnu-emacs@gnu.org; Fri, 21 Jan 2011 12:50:38 -0500 Received: from anne.math.ntnu.no ([129.241.15.150]:55370) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1PgL87-0003EN-PH for bug-gnu-emacs@gnu.org; Fri, 21 Jan 2011 12:50:36 -0500 Received: (qmail 7630 invoked from network); 21 Jan 2011 17:50:30 -0000 Received: from gauss.math.ntnu.no (HELO localhost) (hanche@129.241.15.102) by anne.math.ntnu.no with ESMTPA; 21 Jan 2011 17:50:30 -0000 Date: Fri, 21 Jan 2011 18:50:29 +0100 (CET) Message-Id: <20110121.185029.1304555966254424651.hanche@math.ntnu.no> To: bug-gnu-emacs@gnu.org Subject: 24.0.50; Bad regexp for javascript regexps From: Harald Hanche-Olsen X-URL: http://www.math.ntnu.no/~hanche/ X-Mailer: Mew version 6.3.50 on Emacs 24.0.50 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Spam-Score: -6.1 (------) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.1 (------) 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 ------------=_1295642582-10601-1-- From unknown Tue Aug 19 02:51:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7882: closed Resent-From: Harald Hanche-Olsen Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 21 Jan 2011 21:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7882 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 7882@debbugs.gnu.org, help-debbugs@gnu.org Received: via spool by 7882-submit@debbugs.gnu.org id=B7882.129564411912723 (code B ref 7882); Fri, 21 Jan 2011 21:09:02 +0000 Received: (at 7882) by debbugs.gnu.org; 21 Jan 2011 21:08:39 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PgODm-0003J9-C5 for submit@debbugs.gnu.org; Fri, 21 Jan 2011 16:08:39 -0500 Received: from anne.math.ntnu.no ([129.241.15.150]) by debbugs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1PgODj-0003Iw-Bd for 7882@debbugs.gnu.org; Fri, 21 Jan 2011 16:08:36 -0500 Received: (qmail 2772 invoked from network); 21 Jan 2011 21:16:29 -0000 Received: from gauss.math.ntnu.no (HELO localhost) (hanche@129.241.15.102) by anne.math.ntnu.no with ESMTPA; 21 Jan 2011 21:16:29 -0000 Date: Fri, 21 Jan 2011 22:16:28 +0100 (CET) Message-Id: <20110121.221628.1271751938436426242.hanche@math.ntnu.no> From: Harald Hanche-Olsen In-Reply-To: References: <20110121.185029.1304555966254424651.hanche@math.ntnu.no> X-URL: http://www.math.ntnu.no/~hanche/ X-Mailer: Mew version 6.3.50 on Emacs 24.0.50 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Score: -4.2 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.0 (----) 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