From unknown Tue Sep 09 00:44:22 2025 X-Loop: help-debbugs@gnu.org Subject: bug#24978: 25.1; Bad interaction between nxml-auto-insert-xml-declaration-flag and archive-extract Resent-From: Heinz Rommerskirchen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 21 Nov 2016 13:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 24978 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 24978@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.14797357048985 (code B ref -1); Mon, 21 Nov 2016 13:42:02 +0000 Received: (at submit) by debbugs.gnu.org; 21 Nov 2016 13:41:44 +0000 Received: from localhost ([127.0.0.1]:36786 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c8oqu-0002Kr-2J for submit@debbugs.gnu.org; Mon, 21 Nov 2016 08:41:44 -0500 Received: from eggs.gnu.org ([208.118.235.92]:35818) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c8oqt-0002Ke-1I for submit@debbugs.gnu.org; Mon, 21 Nov 2016 08:41:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c8oqm-0007In-K6 for submit@debbugs.gnu.org; Mon, 21 Nov 2016 08:41:37 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_40 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:37472) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c8oqm-0007Ig-HV for submit@debbugs.gnu.org; Mon, 21 Nov 2016 08:41:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55000) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c8oqk-0001CE-Uu for bug-gnu-emacs@gnu.org; Mon, 21 Nov 2016 08:41:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c8oqh-0007Gx-RE for bug-gnu-emacs@gnu.org; Mon, 21 Nov 2016 08:41:35 -0500 Received: from smtprelay05.ispgateway.de ([80.67.31.99]:50801) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c8oqh-0007Fd-KK for bug-gnu-emacs@gnu.org; Mon, 21 Nov 2016 08:41:31 -0500 Received: from [92.228.67.48] (helo=[192.168.1.244]) by smtprelay05.ispgateway.de with esmtpsa (TLSv1.2:DHE-RSA-AES128-SHA:128) (Exim 4.84) (envelope-from ) id 1c8oqc-0000ys-TW for bug-gnu-emacs@gnu.org; Mon, 21 Nov 2016 14:41:27 +0100 From: Heinz Rommerskirchen Message-ID: <790b5bcd-716f-b4b2-31e8-2fe0c512405c@h-rommerskirchen.de> Date: Mon, 21 Nov 2016 14:41:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Df-Sender: aGVpbnpAaC1yb21tZXJza2lyY2hlbi5kZQ== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) 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: -5.0 (-----) If the variable nxml-auto-insert-xml-declaration-flag is set, an XML declaration is inserted into non-empty XML files inside a zip archive. To reproduce this bug create the valid XML file foo.xml containing === start foo.xml === y === end foo.xml === and pack it into a zip-archive: $ zip -m bar.zip foo.xml Now start "emacs -Q", evaluate "(setq nxml-auto-insert-xml-declaration-flag 't)" in the *scratch* buffer, visit bar.zip with C-x C-f, and press Enter on the entry "foo.xml". foo.xml will be opened and an additional XML declaration is inserted into the buffer rendering the file invalid and marking the buffer as modified. The following simple patch solved the problem for me. === start patch ==== --- nxml-mode-from-25.1.el 2016-11-20 19:45:43.339427354 +0100 +++ nxml-mode.el 2016-11-20 19:48:26.009625534 +0100 @@ -566,7 +566,8 @@ ;; hook. The hook also had the drawback of overriding explicit user ;; instruction to save as some encoding other than utf-8. ;;(add-hook 'write-contents-hooks 'nxml-prepare-to-save) - (when (not (and (buffer-file-name) (file-exists-p (buffer-file-name)))) + (when (and (not (and (buffer-file-name) (file-exists-p (buffer-file-name)))) + (not archive-superior-buffer)) (when (and nxml-default-buffer-file-coding-system (not (local-variable-p 'buffer-file-coding-system))) (setq buffer-file-coding-system nxml-default-buffer-file-coding-system)) === end patch === -- Dr. Heinrich Rommerskirchen Prof.-Schmid-Str. 41 82140 Olching Allemagne Tel. +49 8142 28787 Email heinz@h-rommerskirchen.de From unknown Tue Sep 09 00:44:22 2025 X-Loop: help-debbugs@gnu.org Subject: bug#24978: 25.1; Bad interaction between nxml-auto-insert-xml-declaration-flag and archive-extract Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 27 Jul 2019 12:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24978 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Heinz Rommerskirchen Cc: 24978@debbugs.gnu.org Received: via spool by 24978-submit@debbugs.gnu.org id=B24978.15642289759759 (code B ref 24978); Sat, 27 Jul 2019 12:03:01 +0000 Received: (at 24978) by debbugs.gnu.org; 27 Jul 2019 12:02:55 +0000 Received: from localhost ([127.0.0.1]:43792 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hrLPa-0002XL-Sr for submit@debbugs.gnu.org; Sat, 27 Jul 2019 08:02:55 -0400 Received: from quimby.gnus.org ([80.91.231.51]:37094) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hrLPZ-0002XB-2C for 24978@debbugs.gnu.org; Sat, 27 Jul 2019 08:02:53 -0400 Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=marnie) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hrLPV-0007be-6v; Sat, 27 Jul 2019 14:02:51 +0200 From: Lars Ingebrigtsen References: <790b5bcd-716f-b4b2-31e8-2fe0c512405c@h-rommerskirchen.de> Date: Sat, 27 Jul 2019 14:02:48 +0200 In-Reply-To: <790b5bcd-716f-b4b2-31e8-2fe0c512405c@h-rommerskirchen.de> (Heinz Rommerskirchen's message of "Mon, 21 Nov 2016 14:41:24 +0100") Message-ID: <87mugzit1z.fsf@mouse.gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.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: Heinz Rommerskirchen writes: > If the variable nxml-auto-insert-xml-declaration-flag is set, an XML > declaration is inserted into non-empty XML files inside a zip archive. > > To reproduce this bug create the valid XML file foo. [...] 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: 0.0 (/) 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: -1.0 (-) Heinz Rommerskirchen writes: > If the variable nxml-auto-insert-xml-declaration-flag is set, an XML > declaration is inserted into non-empty XML files inside a zip archive. > > To reproduce this bug create the valid XML file foo.xml containing > === start foo.xml === > > y > === end foo.xml === > and pack it into a zip-archive: > $ zip -m bar.zip foo.xml > Now start "emacs -Q", evaluate > "(setq nxml-auto-insert-xml-declaration-flag 't)" in the *scratch* > buffer, visit bar.zip with C-x C-f, and press Enter on the entry > "foo.xml". foo.xml will be opened and an additional XML declaration is > inserted into the buffer rendering the file invalid and marking the > buffer as modified. (I'm going through older Emacs bug reports that have received no response.) I was able to reproduce the bug in Emacs 27, too. > The following simple patch solved the problem for me. [...] > - (when (not (and (buffer-file-name) (file-exists-p (buffer-file-name)))) > + (when (and (not (and (buffer-file-name) (file-exists-p (buffer-file-name)))) > + (not archive-superior-buffer)) Thanks for the patch, but I think the problem is a bit more general. The intention seems to be to insert the declaration whenever you're starting a new file, so I think a more general solution is to just check whether the buffer is empty before inserting the declaration. I've now done this change on the Emacs trunk. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 27 08:02:59 2019 Received: (at control) by debbugs.gnu.org; 27 Jul 2019 12:02:59 +0000 Received: from localhost ([127.0.0.1]:43795 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hrLPf-0002Xc-5n for submit@debbugs.gnu.org; Sat, 27 Jul 2019 08:02:59 -0400 Received: from quimby.gnus.org ([80.91.231.51]:37108) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hrLPd-0002XU-1I for control@debbugs.gnu.org; Sat, 27 Jul 2019 08:02:57 -0400 Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=marnie) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hrLPa-0007bq-Ey for control@debbugs.gnu.org; Sat, 27 Jul 2019 14:02:56 +0200 Date: Sat, 27 Jul 2019 14:02:54 +0200 Message-Id: <87lfwjit1t.fsf@mouse.gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #24978 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: tags 24978 fixed close 24978 27.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: 0.0 (/) 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: -1.0 (-) tags 24978 fixed close 24978 27.1 quit