From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: meta1729 Newsgroups: gmane.emacs.bugs Subject: bug#64253: 26.3; Bug in revert-buffer-with-coding-system Date: Fri, 23 Jun 2023 12:43:19 +0530 (IST) Message-ID: <20230623.124319.782140973726874654.mail@localhost.localdomain> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32120"; mail-complaints-to="usenet@ciao.gmane.io" Cc: meta1729 To: 64253@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jun 23 17:31:26 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qCikw-0008CW-BC for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 23 Jun 2023 17:31:26 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qCikj-0006Ml-2r; Fri, 23 Jun 2023 11:31:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qCikZ-0006I3-TB for bug-gnu-emacs@gnu.org; Fri, 23 Jun 2023 11:31:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qCikY-0002t7-IE for bug-gnu-emacs@gnu.org; Fri, 23 Jun 2023 11:31:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qCikY-0001nw-91 for bug-gnu-emacs@gnu.org; Fri, 23 Jun 2023 11:31:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: meta1729 Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 23 Jun 2023 15:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 64253 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16875342546912 (code B ref -1); Fri, 23 Jun 2023 15:31:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 23 Jun 2023 15:30:54 +0000 Original-Received: from localhost ([127.0.0.1]:39354 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qCikL-0001nK-QY for submit@debbugs.gnu.org; Fri, 23 Jun 2023 11:30:53 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:57348) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qCaz0-0001w0-Kv for submit@debbugs.gnu.org; Fri, 23 Jun 2023 03:13:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qCaz0-0003wy-DG for bug-gnu-emacs@gnu.org; Fri, 23 Jun 2023 03:13:26 -0400 Original-Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qCayy-0000Vc-Ma for bug-gnu-emacs@gnu.org; Fri, 23 Jun 2023 03:13:26 -0400 Original-Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-25e836b733eso149105a91.0 for ; Fri, 23 Jun 2023 00:13:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687504403; x=1690096403; h=content-transfer-encoding:mime-version:from:subject:cc:to :message-id:date:from:to:cc:subject:date:message-id:reply-to; bh=fTAQRcJgoNe2Jr6EgrU/u0gREKnSPZmRJsZalTCkkAk=; b=CUCQKOXN/R/FZzLdU1vYVb4ntR8JvOY++3v06edCbklF6Uc2L1gT+o8zpNyGlXzaSI nEY2cDNx/mJYGDDlLPUtRLMoKfOh9ALLLkcdq887CjYV7J0i1TsChJ1kXvvs/bMG7FbQ YnKMjIkqszJBaj1IFYcNyDJ8wDqtkksS4+oxlDK1OGT2f5MZtlBLJawziLXaOmPmiK4o 8pkWNEIRJhWZ+Tq/qzNQluX7v6rgOUwpmvm87MERjp0byhdwSS9fHFuMXGdeVD9KbVVj xIzmbrnoM19RyhdSlss22Pi3DURBdcZ4TIgvLru5FXRqsgsWfUUD70l0lI9Vh4qCDth9 MXFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687504403; x=1690096403; h=content-transfer-encoding:mime-version:from:subject:cc:to :message-id:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=fTAQRcJgoNe2Jr6EgrU/u0gREKnSPZmRJsZalTCkkAk=; b=HOIUziOQuDzMR2YPD/kwtowu2ecI2qUh/5s8pE161Uz/Qwr/07bR39qsoqfMEj/t+H nu2H4FFxIp4ayS/OLrYcRH08VwwnRZgG1jNG6SoU2VUEBfB85cPKEpzvnxGyDzNumn+f TRIWIgovQNcXfNWn7MRLP4/N3jv3XBFkIXbkr5hI608HWR4tnteRKHbSq5vFuJ4eCysc 805WnrseRNhA0aeeiOgVoFB0be7XYKZQi82KNtQFbycM/pIuqyugYD2ZahcE3y/6TRuk w4QxjPsXnMef1lgsjX06cqFTeYpkQGxY1m7CHcc3Ka7JfvBOq4JePB6FDOnh1Ng097bZ aWzA== X-Gm-Message-State: AC+VfDxl2e3IPnYuDFBLwAjrR9ZrHGOkA2cpnwGA0N1KukOytE7smC9w Yk6JCXs7UhhTOXPT3S+6/o8= X-Google-Smtp-Source: ACHHUZ4p9HyJ759+aqAw9zmdhKdYEotW41yFdBBRDHZDxa94vOuuRYRty/5gJdfR+R5x0K7luapKjw== X-Received: by 2002:a17:90a:db49:b0:25e:a1c0:af23 with SMTP id u9-20020a17090adb4900b0025ea1c0af23mr15871700pjx.38.1687504402979; Fri, 23 Jun 2023 00:13:22 -0700 (PDT) Original-Received: from vostro ([106.210.225.17]) by smtp.gmail.com with ESMTPSA id 12-20020a17090a01cc00b0024e33c69ee5sm888362pjd.5.2023.06.23.00.13.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jun 2023 00:13:22 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=meta1729@gmail.com; helo=mail-pj1-x102f.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 23 Jun 2023 11:30:48 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:263962 Archived-At: When a buffer is terminated with an un-encodable character, revert-buffer-with-coding-system modifies the buffer in unexpected ways when coding system of the buffer is changed from default iso-latin-1-unix to utf-8-unix, when the visited file contains characters that cannot be encoded in either iso-latin-1-unix or utf-8-unix. Procedure to reproduce the bug. [Create a file which has un-encodable characters and some text between them.] $ echo 3b3b20410a3b3b20420aa80a3b3b20430a3b3b20440aa9 | xxd -r -p > sample Open in Emacs. $ emacs -q -nw --no-site-file -nsl sample Enter: C-h C [describe-coding-system] Output: Coding system for saving this buffer: 1 -- iso-latin-1-unix (alias: iso-8859-1-unix latin-1-unix) Enter: M-x revert-buffer-with-coding-system RET utf-8 RET yes [The buffer has been incorrectly modified. You can see escaped character code at the beginning of buffer, which previously existed at the end of the buffer.] Enter : C-h C [describe-coding-system] Output: Coding system for saving this buffer: U -- utf-8-unix (alias: mule-utf-8-unix cp65001-unix) [Save the buffer to demonstrate that the file has really been incorrectly modified.] Enter: C-x C-w [write-file] Filename: sample2 Select coding system: default raw-text Exit Emacs. C-x C-c $ xxd -p sample2 a93b3b20410a3b3b20420aa80a3b3b20430a3b3b20440a [Compare sample and sample2. Last character (hex code a9) has been moved to beginning of file.] Retry above procedure with different choice for revert-buffer-with-coding-system. Does occur when utf-8 or utf-16 or utf-7 is chosen. Does not occur when iso-2022-7bit is chosen. In GNU Emacs 26.3 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.14) of 2020-03-26, modified by Debian built on lcy01-amd64-020 System Description: Ubuntu 20.04.6 LTS