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#35802: Broken data loaded from uni-decomposition Date: Sat, 22 Jun 2019 18:35:59 -0400 Message-ID: <871rzluu28.fsf@gmail.com> References: <878sv2idc0.fsf@mail.linkov.net> <85k1dybq2y.fsf@gmail.com> <87v9xie9a8.fsf@mail.linkov.net> <854l4wb3y6.fsf@gmail.com> <877e9r3j2i.fsf@mail.linkov.net> <87k1dmxopz.fsf@gmail.com> <877e9lcp3s.fsf@mail.linkov.net> <87muibur1i.fsf@gmail.com> <877e9e3jqv.fsf@mail.linkov.net> 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="227975"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) Cc: 35802@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jun 23 00:37:12 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 1heodE-000xAv-IA for geb-bug-gnu-emacs@m.gmane.org; Sun, 23 Jun 2019 00:37:12 +0200 Original-Received: from localhost ([::1]:42614 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1heodD-00049x-4x for geb-bug-gnu-emacs@m.gmane.org; Sat, 22 Jun 2019 18:37:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60743) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1heod6-00047d-93 for bug-gnu-emacs@gnu.org; Sat, 22 Jun 2019 18:37:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1heod4-00032H-LE for bug-gnu-emacs@gnu.org; Sat, 22 Jun 2019 18:37:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39111) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1heod4-00031z-FD for bug-gnu-emacs@gnu.org; Sat, 22 Jun 2019 18:37:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1heod4-0007Hh-30 for bug-gnu-emacs@gnu.org; Sat, 22 Jun 2019 18:37: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: Sat, 22 Jun 2019 22:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35802 X-GNU-PR-Package: emacs Original-Received: via spool by 35802-submit@debbugs.gnu.org id=B35802.156124297027928 (code B ref 35802); Sat, 22 Jun 2019 22:37:02 +0000 Original-Received: (at 35802) by debbugs.gnu.org; 22 Jun 2019 22:36:10 +0000 Original-Received: from localhost ([127.0.0.1]:52655 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1heocD-0007GJ-Mb for submit@debbugs.gnu.org; Sat, 22 Jun 2019 18:36:10 -0400 Original-Received: from mail-io1-f45.google.com ([209.85.166.45]:34243) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1heocB-0007Fq-6O; Sat, 22 Jun 2019 18:36:07 -0400 Original-Received: by mail-io1-f45.google.com with SMTP id k8so106269iot.1; Sat, 22 Jun 2019 15:36:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=RpW6mdg4V9dIAwWtnyVEy0lIgInOzjyZo0nZ9RsGJXg=; b=PYtBH01XuwzHHEMCucAYWvt1VT3UdfgMqPTEFTmSgmFUyJVSO1UP9+PGRS/QqzxJ9K dNdnuopa/TCSr5cVlFSrr8fLlA4yLOOlwdOzXBXUfGT8VqbxmQo9uMnrQdsCKOZi/f5+ FC/dwbs93nUUaMmDtoK/tx2utXrRCO2obSP0r7E3QevkLlV8NqSFkniKxbfh8Zp6JyMb NbIH0u0WhlcaR31jrEse1KTc/YmYKL9/NTWCqUMNI6FgB1sVtzkccHZipPr6Un8y58jr u2AtRdMxlLQMtiqKyFN6S6mH1hxH0clZnTFjNLgkaLiOzk0mNndtf15Al96julphDoT/ +DbQ== 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:references:date:in-reply-to :message-id:user-agent:mime-version; bh=RpW6mdg4V9dIAwWtnyVEy0lIgInOzjyZo0nZ9RsGJXg=; b=T9eDZGigJOJlETh9ViImzaFvHl2FJI4ONcMcASWWEALSA5afVcpsO68xeaYq8F7NH5 iggWylcmAmbjsaZ4dG29uFhVuXJjQDh7S1bCqA5Z0RXY1+lRtr8kWAgUqWZ4MAlBWwIC T+r5XT5p8+eCy6uMTPs23rMFRo4A+yqlrTqwjENa+xtutoSMMz6ki67a0Alp78xVx01v xwZ8RoN+UverUXFflBWz3NKpH6/3tokjKdm0sbklWaVPMhY31W2PSB29wz0fyQtcKlTI TsS3LBahpoZV4yNUDpzBoE65BMcE0oGl4BfdKnhpF6BkakVkAXPW98ON7qDeqRkBxVRt RjBg== X-Gm-Message-State: APjAAAXJYEgrrlM+0Hts8H43NP/dWcMtJykWZVoMapMRrD9fCVVT47Hg urPRApO0laT9HxFggTiA4qL3JYvJ X-Google-Smtp-Source: APXvYqxXrXxYWzAVtZ3hHiexom0qeWAnpvVLUyLAJBD4fXVubnoXuVfn1dXV0PzL61fGEhp93SaFpg== X-Received: by 2002:a5d:9bc6:: with SMTP id d6mr18188012ion.160.1561242961410; Sat, 22 Jun 2019 15:36:01 -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 d7sm5848855iob.67.2019.06.22.15.35.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 22 Jun 2019 15:36:00 -0700 (PDT) In-Reply-To: <877e9e3jqv.fsf@mail.linkov.net> (Juri Linkov's message of "Fri, 21 Jun 2019 22:16:24 +0300") 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:161069 Archived-At: --=-=-= Content-Type: text/plain tags 35802 + patch quit Juri Linkov writes: >> So I think adjusting isearch-search-fun-default should be enough >> to fix this. > > Yes, hopefully the value of search-spaces-regexp is not needed at the > time of regexp generation, even though it's mentioned in the comments > of char-fold-to-regexp. Right, it only affects searching. > Are more changes required to avoid such problem in other error-prone > places and to make char-fold--test-bug-35802 still to pass, like using > "Local[ ]Variables:" in find-auto-coding? I don't think it's reasonable to start protecting all regexps which might have whitespace in them. > Also maybe a warning about the need of using non-capturing groups should be > added to documentation of search-spaces-regexp, search-whitespace-regexp, > Info-search-whitespace-regexp? Right, I forgot about that. --=-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename=0001-Don-t-bind-search-spaces-regexp-around-possible-auto.patch Content-Transfer-Encoding: quoted-printable Content-Description: patch >From 9bc358511c1240f1c49c12cd84e34210d7cbc16b Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Fri, 21 Jun 2019 07:09:44 -0400 Subject: [PATCH] Don't bind search-spaces-regexp around possible autoload (Bug#35802) * lisp/isearch.el (isearch-search-fun-default): Move possible autoload trigger outside let-binding of search-spaces-regexp. * lisp/char-fold.el (char-fold-make-table): Remove no longer needed workaround. * lisp/info.el (Info-search-whitespace-regexp): * lisp/isearch.el (search-whitespace-regexp): * src/search.c (syms_of_search) : Add warning about adding capturing groups to the value. * test/lisp/char-fold-tests.el: Remove, binding search-spaces-regexp to a different should be considered a bug. --- lisp/char-fold.el | 1 - lisp/info.el | 4 +++- lisp/isearch.el | 44 ++++++++++++++++++++++++++--------------= ---- src/search.c | 4 +++- test/lisp/char-fold-tests.el | 8 -------- 5 files changed, 32 insertions(+), 29 deletions(-) diff --git a/lisp/char-fold.el b/lisp/char-fold.el index 7a79873873..7b0e55bb11 100644 --- a/lisp/char-fold.el +++ b/lisp/char-fold.el @@ -28,7 +28,6 @@ (eval-and-compile (defun char-fold-make-table () (let* ((equiv (make-char-table 'char-fold-table)) (equiv-multi (make-char-table 'char-fold-table)) - (search-spaces-regexp nil) ; workaround for bug#35802 (table (unicode-property-table-internal 'decomposition))) (set-char-table-extra-slot equiv 0 equiv-multi) =20 diff --git a/lisp/info.el b/lisp/info.el index c211887a39..3203c5f171 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -343,7 +343,9 @@ (defcustom Info-search-whitespace-regexp "\\s-+" This applies to Info search for regular expressions. You might want to use something like \"[ \\t\\r\\n]+\" instead. In the Customization buffer, that is `[' followed by a space, -a tab, a carriage return (control-M), a newline, and `]+'." +a tab, a carriage return (control-M), a newline, and `]+'. Don't +add any capturing groups into this value; that can change the +numbering of existing capture groups in unexpected ways." :type 'regexp :group 'info) =20 diff --git a/lisp/isearch.el b/lisp/isearch.el index bb29c2914b..f150a3bba4 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -129,8 +129,10 @@ (defcustom search-whitespace-regexp (purecopy "\\s-+") then each space you type matches literally, against one space. =20 You might want to use something like \"[ \\t\\r\\n]+\" instead. -In the Customization buffer, that is `[' followed by a space, -a tab, a carriage return (control-M), a newline, and `]+'." +In the Customization buffer, that is `[' followed by a space, a +tab, a carriage return (control-M), a newline, and `]+'. Don't +add any capturing groups into this value; that can change the +numbering of existing capture groups in unexpected ways." :type '(choice (const :tag "Match Spaces Literally" nil) regexp) :version "24.3") @@ -3263,25 +3265,31 @@ (defun isearch--lax-regexp-function-p () (defun isearch-search-fun-default () "Return default functions to use for the search." (lambda (string &optional bound noerror count) - ;; Use lax versions to not fail at the end of the word while - ;; the user adds and removes characters in the search string - ;; (or when using nonincremental word isearch) - (let ((search-spaces-regexp (when (cond - (isearch-regexp isearch-regexp-lax-= whitespace) - (t isearch-lax-whitespace)) + (let (;; Evaluate this before binding `search-spaces-regexp' which + ;; can break all sorts of regexp searches. In particular, + ;; calling `isearch-regexp-function' can trigger autoloading + ;; (Bug#35802). + (regexp + (cond (isearch-regexp-function + (let ((lax (and (not bound) + (isearch--lax-regexp-function-p)))) + (when lax + (setq isearch-adjusted t)) + (if (functionp isearch-regexp-function) + (funcall isearch-regexp-function string lax) + (word-search-regexp string lax)))) + (isearch-regexp string) + (t (regexp-quote string)))) + ;; Use lax versions to not fail at the end of the word while + ;; the user adds and removes characters in the search string + ;; (or when using nonincremental word isearch) + (search-spaces-regexp (when (if isearch-regexp + isearch-regexp-lax-whitespace + isearch-lax-whitespace) search-whitespace-regexp))) (funcall (if isearch-forward #'re-search-forward #'re-search-backward) - (cond (isearch-regexp-function - (let ((lax (and (not bound) (isearch--lax-regexp-function-p)= ))) - (when lax - (setq isearch-adjusted t)) - (if (functionp isearch-regexp-function) - (funcall isearch-regexp-function string lax) - (word-search-regexp string lax)))) - (isearch-regexp string) - (t (regexp-quote string))) - bound noerror count)))) + regexp bound noerror count)))) =20 (defun isearch-search-string (string bound noerror) "Search for the first occurrence of STRING or its translation. diff --git a/src/search.c b/src/search.c index 8a0f707b72..fa574959fb 100644 --- a/src/search.c +++ b/src/search.c @@ -3390,7 +3390,9 @@ syms_of_search (void) Some commands use this for user-specified regexps. Spaces that occur inside character classes or repetition operators or other such regexp constructs are not replaced with this. -A value of nil (which is the normal value) means treat spaces literally. = */); +A value of nil (which is the normal value) means treat spaces +literally. Note that a value with capturing groups can change the +numbering of existing capture groups in unexpected ways. */); Vsearch_spaces_regexp =3D Qnil; =20 DEFSYM (Qinhibit_changing_match_data, "inhibit-changing-match-data"); diff --git a/test/lisp/char-fold-tests.el b/test/lisp/char-fold-tests.el index 8a7414084b..3fde312a13 100644 --- a/test/lisp/char-fold-tests.el +++ b/test/lisp/char-fold-tests.el @@ -124,13 +124,5 @@ (ert-deftest char-fold--speed-test () ;; Ensure it took less than a second. (should (< (- (time-to-seconds) time) 1)))))) =20 -(ert-deftest char-fold--test-bug-35802 () - (let* ((char-code-property-alist ; initial value - (cons '(decomposition . "uni-decomposition.el") - char-code-property-alist)) - (search-spaces-regexp "\\(\\s-\\|\n\\)+") - (char-fold-table (char-fold-make-table))) - (char-fold--test-match-exactly "a=CC=88" "=C3=A4"))) - (provide 'char-fold-tests) ;;; char-fold-tests.el ends here --=20 2.11.0 --=-=-=--