From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#36347: 26.2.90; fontification mistakes contraction for a string in HTML Date: Sun, 23 Jun 2019 21:47:00 -0400 Message-ID: <875zovu54b.fsf@gmail.com> References: <23158.1561337072@alto> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="128137"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) Cc: 36347@debbugs.gnu.org To: Mike Kupfer Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jun 24 03:48:17 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hfE5e-000X8O-KP for geb-bug-gnu-emacs@m.gmane.org; Mon, 24 Jun 2019 03:48:14 +0200 Original-Received: from localhost ([::1]:47586 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfE5d-0000vY-Hi for geb-bug-gnu-emacs@m.gmane.org; Sun, 23 Jun 2019 21:48:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48551) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfE5V-0000vO-0s for bug-gnu-emacs@gnu.org; Sun, 23 Jun 2019 21:48:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfE5T-0002aE-IO for bug-gnu-emacs@gnu.org; Sun, 23 Jun 2019 21:48:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41781) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hfE5S-0002WJ-Lr for bug-gnu-emacs@gnu.org; Sun, 23 Jun 2019 21:48:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hfE5S-0006B2-IC for bug-gnu-emacs@gnu.org; Sun, 23 Jun 2019 21:48:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 24 Jun 2019 01:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36347 X-GNU-PR-Package: emacs Original-Received: via spool by 36347-submit@debbugs.gnu.org id=B36347.156134084023686 (code B ref 36347); Mon, 24 Jun 2019 01:48:02 +0000 Original-Received: (at 36347) by debbugs.gnu.org; 24 Jun 2019 01:47:20 +0000 Original-Received: from localhost ([127.0.0.1]:55325 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hfE4m-00069y-6S for submit@debbugs.gnu.org; Sun, 23 Jun 2019 21:47:20 -0400 Original-Received: from mail-io1-f44.google.com ([209.85.166.44]:40804) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hfE4h-00069e-ER for 36347@debbugs.gnu.org; Sun, 23 Jun 2019 21:47:16 -0400 Original-Received: by mail-io1-f44.google.com with SMTP id n5so26832ioc.7 for <36347@debbugs.gnu.org>; Sun, 23 Jun 2019 18:47:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version; bh=HGL84FKrC3E8WQWs9M1wqkAoVHQ7n+wsoAkEU1E5/gg=; b=tdZIVePd1Wd8x1cWClzI2vMY/8SYudY8vuiMmZyQ/ve55WI740yl4YW4hb17aQR7wT qyIFhi6/iB/iSHqMzd2EZGHXVY7KrCT3JYyGnZKKbM50zEFVg9SSyC9lpT3kjpDb6KtC b3KKufkHSmi/rxQ1N/EADdGlesqbFX8wm7qHXB+ld9M8F2xfBk8GbgOXU1soP2v3Q1K8 s3HJAPEWeoTj6Ez3/TLQtSbVq4tFvcXSx2xSeZWS5RqBZy8pg5DPuAh4txnufg9qKXQA J5mY/NZw9sUG+evvMt14ylOKAutpFq5L6bYpcjBF8nqsLZKT6Z7o0Q2acZqEzYBXOgMH 2fhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references :user-agent:date:message-id:mime-version; bh=HGL84FKrC3E8WQWs9M1wqkAoVHQ7n+wsoAkEU1E5/gg=; b=omEvWub+ewMmK7L+8g5qbDVdZf3X1SutH7ycjgiBxxVh8dlf3jO51+nu+IurtEPRfo 3FJkI9UVAduPKlp9xn5YyuiTDzXl3SZl1F7OqmqrPchQyI2XwTWpCYNrQny+dD3WjTuL eSN/LDuE1Ihz3VHt1Gs28THvT1qD7Wh7h1L+zonilnSkLOvPHN69sgPRNwKUYgnoLPKU li/zEVB9h0SyzCRoVGdkbr7hAj3MVfmg2xxWtSmwxjlQyaYsJ49QyyrHE6d0aVpu0BvQ n2zdV0gZWes510mujc1oc0Tr61UxRxY109aKkHL+tTlbUcWS0ct8VvO4Dmv9h9y5fo8L Y+JA== X-Gm-Message-State: APjAAAV5dd2Y992R+iMWRWtY8fJIqUO4m7f9r0AJ6Sa5KS+qv0D/aktW xVekqZIpWkrhCvkDy8m5l/k8fcs4 X-Google-Smtp-Source: APXvYqynbItT3szWENs2XPTPMpaPmmA0s5Ix190rASg0EQxDSV0doocouhNOaOlqVUGYE5bHAXfhPA== X-Received: by 2002:a02:6996:: with SMTP id e144mr17870770jac.47.1561340829464; Sun, 23 Jun 2019 18:47:09 -0700 (PDT) Original-Received: from minid (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.gmail.com with ESMTPSA id f4sm19003096iok.56.2019.06.23.18.47.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Jun 2019 18:47:08 -0700 (PDT) In-Reply-To: <23158.1561337072@alto> (Mike Kupfer's message of "Sun, 23 Jun 2019 17:44:32 -0700") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:161190 Archived-At: --=-=-= Content-Type: text/plain Mike Kupfer writes: > To reproduce: > > 1. start emacs with -Q > 2. Visit (C-x C-f) the attached file (foo.html). > > When I do this with 26.2.90, the text starting with the apostrophe in > "doesn't", and ending at the end of file, is fontified as a string. > > When I do this with 26.2-rc1, the text is fontified as I would expect > (HTML tags are in blue, everything else is in the default black or dark > gray). The problem is the parens around the quote, sgml-mode uses the wrong syntax table during propertizing. The only reason it doesn't show up in 26.2 is because sgml-mode fails to fontify single quoted strings at all. The same problem exists in 26.2 and earlier with double quote, although it's less likely to have an unmatched double quote in text. (") (') So the question is what to do about this for the release branch. 1. Revert the fix which adds handling of single quotes. This means single quotes never cause highlighting, even when they should. This is a regression in nxml-mode relative to Emacs 25, but sgml-mode worked like that for a while already (in Emacs 26, nxml-mode was changed to rely on some of sgml-mode's code). 2. Fix this bug with the patch below, it's fairly small and straightforward. And also, can be disabled by setting syntax-ppss-table to nil in sgml-mode-hook. 3. Do nothing (for 26.3, that is). --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Fix-sgml-mode-handling-of-quotes-within-parens-Bug-3.patch Content-Description: patch >From cb2f5380e3e78b7d956c604c03c21122c8ced36d Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sun, 23 Jun 2019 21:27:43 -0400 Subject: [PATCH] Fix sgml-mode handling of quotes within parens (Bug#36347) * lisp/textmodes/sgml-mode.el (sgml-syntax-propertize): Use syntax-ppss-table if set. This is only needed on the release branch, on master the caller (syntax-propertize) already does this. (sgml-mode): Set syntax-ppss-table to sgml-tag-syntax-table. This correctly classifies parens as punctuation, so they won't confuse the parser. * test/lisp/textmodes/sgml-mode-tests.el (sgml-tests--quotes-syntax): New test copied from master, with two cases added for this bug. --- lisp/textmodes/sgml-mode.el | 10 ++++++---- test/lisp/textmodes/sgml-mode-tests.el | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 128e58810e..895ce844e9 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -357,10 +357,11 @@ (eval-and-compile (defun sgml-syntax-propertize (start end) "Syntactic keywords for `sgml-mode'." (goto-char start) - (sgml-syntax-propertize-inside end) - (funcall - (syntax-propertize-rules sgml-syntax-propertize-rules) - start end)) + (with-syntax-table (or syntax-ppss-table (syntax-table)) ; Not needed on master. + (sgml-syntax-propertize-inside end) + (funcall + (syntax-propertize-rules sgml-syntax-propertize-rules) + start end))) (defun sgml-syntax-propertize-inside (end) (let ((ppss (syntax-ppss))) @@ -568,6 +569,7 @@ (define-derived-mode sgml-mode text-mode '(sgml-xml-mode "XML" "SGML") sgml-font-lock-keywords-2) nil t)) (setq-local syntax-propertize-function #'sgml-syntax-propertize) + (setq-local syntax-ppss-table sgml-tag-syntax-table) (setq-local facemenu-add-face-function 'sgml-mode-facemenu-add-face-function) (setq-local sgml-xml-mode (sgml-xml-guess)) (unless sgml-xml-mode diff --git a/test/lisp/textmodes/sgml-mode-tests.el b/test/lisp/textmodes/sgml-mode-tests.el index 7318a667b3..0000b352ff 100644 --- a/test/lisp/textmodes/sgml-mode-tests.el +++ b/test/lisp/textmodes/sgml-mode-tests.el @@ -130,5 +130,27 @@ (ert-deftest sgml-delete-tag-bug-8203-should-not-delete-apostrophe () (sgml-delete-tag 1) (should (string= "Winter is comin'" (buffer-string))))) +(ert-deftest sgml-tests--quotes-syntax () + (dolist (str '("a\"b c'd" + "a'b c\"d" + "\"a'" + "'a\"" + "\"a'\"" + "'a\"'" + "a\"b c'd" + ;;"c>'d" Fixed in master. + "" + "" + "(')" + "(\")" + )) + (with-temp-buffer + (sgml-mode) + (insert str) + (ert-info ((format "%S" str) :prefix "Test case: ") + ;; Check that last tag is parsed as a tag. + (should (= 1 (car (syntax-ppss (1- (point-max)))))) + (should (= 0 (car (syntax-ppss (point-max))))))))) + (provide 'sgml-mode-tests) ;;; sgml-mode-tests.el ends here -- 2.11.0 --=-=-=--