From unknown Sat Aug 16 11:12:14 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#53965 <53965@debbugs.gnu.org> To: bug#53965 <53965@debbugs.gnu.org> Subject: Status: 29.0.50; Subject: [PATCH] ietf-drums-remove-whitespace fails on unmatched " and ( Reply-To: bug#53965 <53965@debbugs.gnu.org> Date: Sat, 16 Aug 2025 18:12:14 +0000 retitle 53965 29.0.50; Subject: [PATCH] ietf-drums-remove-whitespace fails = on unmatched " and ( reassign 53965 emacs submitter 53965 Bob Rogers severity 53965 normal tag 53965 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 12 17:03:58 2022 Received: (at submit) by debbugs.gnu.org; 12 Feb 2022 22:03:58 +0000 Received: from localhost ([127.0.0.1]:35850 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nJ0Un-0001yE-UK for submit@debbugs.gnu.org; Sat, 12 Feb 2022 17:03:58 -0500 Received: from lists.gnu.org ([209.51.188.17]:32804) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nJ0Um-0001y6-7G for submit@debbugs.gnu.org; Sat, 12 Feb 2022 17:03:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55104) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nJ0Ul-00013D-SO for bug-gnu-emacs@gnu.org; Sat, 12 Feb 2022 17:03:55 -0500 Received: from [2607:f8b0:4864:20::731] (port=34471 helo=mail-qk1-x731.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nJ0Ui-0007Hn-3f for bug-gnu-emacs@gnu.org; Sat, 12 Feb 2022 17:03:54 -0500 Received: by mail-qk1-x731.google.com with SMTP id bs32so11326880qkb.1 for ; Sat, 12 Feb 2022 14:03:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rgrjr-com.20210112.gappssmtp.com; s=20210112; h=from:to:subject:date:message-id:mime-version; bh=J0nFsogWc5vJyIKsHnTYEKpnc+T7cuHmEOeDl6XINk8=; b=iqH+Gkvkj0kYZsUK27z9pIR+fnTZkf1u5UeDC3Shv7V9AZ9AHGCZtqjRBEy1WqPchZ 1Glqh10lQ4OvUN2NNBiCsDc0vvMZaajpsfS3FUDm9j5xB0efUQfALUSMxzDVqh6b5qKu qinVIOqiPLy39gYXSwS/FDLDcl8DZylNMJnoHzB3kzUm690wZAplM5nUmlv2u5nBN4pr EKIct/uVLoimlzT0bZuiBrQAO6p8oozA5ncpgUNEgpCv5ty4+cyHuif02zRZXB5RvCln hB9YbNfMA4BWrD1CRlXLUtUY/gYUB+D7PGnFUMePed2yChPczGrGkz2/9T4raQVNlseI 480g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=J0nFsogWc5vJyIKsHnTYEKpnc+T7cuHmEOeDl6XINk8=; b=zcAb7ZuNsDBbUGyeV6TQsVRiZVFCB0wLScilckfagvgkkhGvVvgWXcfPMhoF6zjBPi T25LGw1KJZYZfs4oYBqQlM/wsgWwzPgtOw8McVPQH6NcFTCSn2H9twBvfVzn9sVQcuxu /Aleu/hUmSsuCgnRPN2DD18vHnN+s0hHPl9QtM1F3W2OGFKRVY1PUq44JUZuHqIXPg19 9v/NwpJ6R5OxlE/NlAB6YcETi54Np7Pj60sDZmuF7jTp5oNWQCEVt3lTjv44CAxsPQdF f92AevgLvl6j6eLQfgwVNSlhC1+CzPFLm5aEbK+xpY7eSv6NdWubQDQ875erhQSrQZa9 olOg== X-Gm-Message-State: AOAM532wLbuZWJWfu0L96EJ+t6T0T2tHzp87ZB3hNSjlBSC3fe4214IU X5dRvd7wNyEBWNIl2e8V3wjWMw== X-Google-Smtp-Source: ABdhPJyr2bMvfzbC4iXBGXupqaBFeK5DEC/G+JtStA+e0bDWxUNbhHL/dA4Z+25ahlW83olTrlJpew== X-Received: by 2002:a05:620a:298a:: with SMTP id r10mr3764016qkp.295.1644703428940; Sat, 12 Feb 2022 14:03:48 -0800 (PST) Received: from orion.rgrjr.com ([2601:19c:4600:3270::c]) by smtp.gmail.com with ESMTPSA id c21sm14927584qtx.89.2022.02.12.14.03.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Feb 2022 14:03:48 -0800 (PST) From: Bob Rogers To: bug-gnu-emacs@gnu.org Subject: 29.0.50; Subject: [PATCH] ietf-drums-remove-whitespace fails on unmatched " and ( Date: Sat, 12 Feb 2022 17:03:47 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::731 (failed) Received-SPF: none client-ip=2607:f8b0:4864:20::731; envelope-from=rogers@rgrjr.com; helo=mail-qk1-x731.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0) of 2022-02-10 built on orion Repository revision: 2469e036035f8f5baa78e1557c61df019d8fd572 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12003000 System Description: openSUSE Leap 15.3 Configured using: 'configure --with-dbus=no --with-gsettings=no --with-gif=ifavailable --with-tiff=no --with-gnutls=yes --with-gconf=no' Configured features: ACL CAIRO FREETYPE GIF GLIB GMP GNUTLS HARFBUZZ JPEG LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3 ZLIB Evaluating (e.g.) (ietf-drums-remove-whitespace "random (unterminated comment") gets a scan-error, and similarly if the "(" is replaced with a "\"". The patch below makes it work, does some code consolidation, and adds regression tests. -- Bob Rogers http://www.rgrjr.com/ ------------------------------------------------------------------------ >From 97083141917360149b65851f4615fabc0d8c9462 Mon Sep 17 00:00:00 2001 From: Bob Rogers Date: Fri, 11 Feb 2022 23:42:17 -0500 Subject: [PATCH] Fix ietf-drums-remove-whitespace unmatched " and ( * lisp/mail/ietf-drums.el: + (ietf-drums-skip-comment): New helper function. + (ietf-drums-remove-comments): Use ietf-drums-skip-comment. + (ietf-drums-remove-whitespace): Handle unterminated quotes and comments, as ietf-drums-remove-comments already does. * test/lisp/mail/ietf-drums-tests.el: + Test unterminated quote and comment for ietf-drums-remove-whitespace and ietf-drums-remove-comments. --- lisp/mail/ietf-drums.el | 30 ++++++++++++++++++++---------- test/lisp/mail/ietf-drums-tests.el | 16 ++++++++++++++++ 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/lisp/mail/ietf-drums.el b/lisp/mail/ietf-drums.el index db77aba172..886de7c9d6 100644 --- a/lisp/mail/ietf-drums.el +++ b/lisp/mail/ietf-drums.el @@ -65,6 +65,21 @@ ietf-drums-syntax-table (modify-syntax-entry ?\' "_" table) table)) +(defvar ietf-drums-comment-syntax-table + (let ((table (copy-syntax-table ietf-drums-syntax-table))) + (modify-syntax-entry ?\" "w" table) + table) + "In comments, DQUOTE is normal and does not start a string.") + +(defun ietf-drums--skip-comment () + ;; From just before the start of a comment, go to the end. Returns + ;; point. If the comment is unterminated, go to point-max. + (condition-case () + (with-syntax-table ietf-drums-comment-syntax-table + (forward-sexp 1)) + (scan-error (goto-char (point-max)))) + (point)) + (defun ietf-drums-token-to-list (token) "Translate TOKEN into a list of characters." (let ((i 0) @@ -109,14 +124,7 @@ ietf-drums-remove-comments (forward-sexp 1) (error (goto-char (point-max))))) ((eq c ?\() - (delete-region - (point) - (condition-case nil - (with-syntax-table (copy-syntax-table ietf-drums-syntax-table) - (modify-syntax-entry ?\" "w") - (forward-sexp 1) - (point)) - (error (point-max))))) + (delete-region (point) (ietf-drums--skip-comment))) (t (forward-char 1)))) (buffer-string)))) @@ -130,9 +138,11 @@ ietf-drums-remove-whitespace (setq c (char-after)) (cond ((eq c ?\") - (forward-sexp 1)) + (condition-case () + (forward-sexp 1) + (scan-error (goto-char (point-max))))) ((eq c ?\() - (forward-sexp 1)) + (ietf-drums--skip-comment)) ((memq c '(?\ ?\t ?\n ?\r)) (delete-char 1)) (t diff --git a/test/lisp/mail/ietf-drums-tests.el b/test/lisp/mail/ietf-drums-tests.el index 4cc38b8763..b13937bf73 100644 --- a/test/lisp/mail/ietf-drums-tests.el +++ b/test/lisp/mail/ietf-drums-tests.el @@ -40,6 +40,16 @@ ietf-drums-tests (should (equal (ietf-drums-remove-comments "random (first) (second (and)) (third) not fourth") "random not fourth")) + ;; Test some unterminated comments. + (should (equal (ietf-drums-remove-comments "test an (unterminated comment") + "test an ")) + (should (equal (ietf-drums-remove-comments "test an \"unterminated quote") + ;; returns the string unchanged (and doesn't barf). + "test an \"unterminated quote")) + (should (equal (ietf-drums-remove-comments + ;; note that double-quote is not special. + "test (unterminated comments with \"quoted (\" )stuff") + "test ")) ;; ietf-drums-remove-whitespace (should (equal (ietf-drums-remove-whitespace "random string") @@ -53,6 +63,12 @@ ietf-drums-tests (should (equal (ietf-drums-remove-whitespace "random (first) (second (and)) (third) not fourth") "random(first)(second (and))(third)notfourth")) + ;; Test some unterminated comments and quotes. + (should (equal (ietf-drums-remove-whitespace + "random (first) (second (and)) (third unterminated") + "random(first)(second (and))(third unterminated")) + (should (equal (ietf-drums-remove-whitespace "random \"non terminated string") + "random\"non terminated string")) ;; ietf-drums-strip (should (equal (ietf-drums-strip "random string") "randomstring")) -- 2.34.1 From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 13 03:33:01 2022 Received: (at 53965) by debbugs.gnu.org; 13 Feb 2022 08:33:01 +0000 Received: from localhost ([127.0.0.1]:36205 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nJAJY-0005ON-Qy for submit@debbugs.gnu.org; Sun, 13 Feb 2022 03:33:00 -0500 Received: from quimby.gnus.org ([95.216.78.240]:50672) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nJAJW-0005MP-6g for 53965@debbugs.gnu.org; Sun, 13 Feb 2022 03:32:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=8fziCSNpwNCrScq0aJNBW1O1gwoQeqXEef2UltMtsmw=; b=vZKpTYk7bETH/m4HN8APN59tO/ wOG+HruMMi05UuR1GSrOncJNa1ztt+ErXEFxeSPJKEJ53KD+sqy3tAGxmRk9mJfTTsRJzrXk3bG7P Kt6c98gE2j0J3weGIhBO6+uN5aMJAg6dKi14N5N/lgvxX0bsN7VgNc+jkngmsjquhP/c=; Received: from [84.212.220.105] (helo=giant) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nJAJM-0000bL-W1; Sun, 13 Feb 2022 09:32:51 +0100 From: Lars Ingebrigtsen To: Bob Rogers Subject: Re: bug#53965: 29.0.50; Subject: [PATCH] ietf-drums-remove-whitespace fails on unmatched " and ( References: X-Now-Playing: Sidsel Endresen's _Undertow_: "You Cover Time" Date: Sun, 13 Feb 2022 09:32:46 +0100 In-Reply-To: (Bob Rogers's message of "Sat, 12 Feb 2022 17:03:47 -0500") Message-ID: <87czjryxn5.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Bob Rogers writes: > The patch below makes it work, does some code consolidation, and adds > regression tests. Thanks; pushed to Emacs 29 (with some indentation changes). Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 53965 Cc: 53965@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Bob Rogers writes: > The patch below makes it work, does some code consolidation, and adds > regression tests. Thanks; pushed to Emacs 29 (with some indentation changes). -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 13 03:33:10 2022 Received: (at control) by debbugs.gnu.org; 13 Feb 2022 08:33:10 +0000 Received: from localhost ([127.0.0.1]:36209 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nJAJi-0005P9-13 for submit@debbugs.gnu.org; Sun, 13 Feb 2022 03:33:10 -0500 Received: from quimby.gnus.org ([95.216.78.240]:50688) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nJAJg-0005Ou-6l for control@debbugs.gnu.org; Sun, 13 Feb 2022 03:33:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=FaJQcsGkGBPQZSoLszSj5OVadRaSITFAIHN87qWduU8=; b=ATcO6KSBGLubUZPy7M1HmhRUTG KWkmF4QS8bnXueOOgEl/9jAh44xcDGVNJ74PbO65TOZgeni6VYGPdsPu0iGtIhI6CR15SToVxMLsB viKwgd+nHzk1Ylw2pcmllwk7Le8JC1MlI2H7Py0Up4SlH2lcuUmRm8hq4LhnN3KpXtfQ=; Received: from [84.212.220.105] (helo=giant) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nJAJX-0000bT-KI for control@debbugs.gnu.org; Sun, 13 Feb 2022 09:33:01 +0100 Date: Sun, 13 Feb 2022 09:32:56 +0100 Message-Id: <87bkzbyxmv.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #53965 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: close 53965 29.1 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) close 53965 29.1 quit From unknown Sat Aug 16 11:12:14 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 13 Mar 2022 11:24:08 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator