GNU bug report logs - #64253
26.3; Bug in revert-buffer-with-coding-system

Previous Next

Package: emacs;

Reported by: meta1729 <meta1729 <at> gmail.com>

Date: Fri, 23 Jun 2023 15:31:02 UTC

Severity: normal

Found in version 26.3

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 64253 in the body.
You can then email your comments to 64253 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#64253; Package emacs. (Fri, 23 Jun 2023 15:31:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to meta1729 <meta1729 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 23 Jun 2023 15:31:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: meta1729 <meta1729 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Cc: meta1729 <meta1729 <at> gmail.com>
Subject: 26.3; Bug in revert-buffer-with-coding-system
Date: Fri, 23 Jun 2023 12:43:19 +0530 (IST)
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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#64253; Package emacs. (Sat, 24 Jun 2023 08:52:01 GMT) Full text and rfc822 format available.

Message #8 received at 64253 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: meta1729 <meta1729 <at> gmail.com>
Cc: 64253 <at> debbugs.gnu.org
Subject: Re: bug#64253: 26.3; Bug in revert-buffer-with-coding-system
Date: Sat, 24 Jun 2023 11:51:39 +0300
> Cc: meta1729 <meta1729 <at> gmail.com>
> Date: Fri, 23 Jun 2023 12:43:19 +0530 (IST)
> From: meta1729 <meta1729 <at> gmail.com>
> 
> 
> 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.]

Thanks.  This 21-year old bug (a simple omission of a single code
line) should now be fixed on the emacs-29 branch.




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sat, 01 Jul 2023 08:31:02 GMT) Full text and rfc822 format available.

Notification sent to meta1729 <meta1729 <at> gmail.com>:
bug acknowledged by developer. (Sat, 01 Jul 2023 08:31:02 GMT) Full text and rfc822 format available.

Message #13 received at 64253-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: meta1729 <at> gmail.com
Cc: 64253-done <at> debbugs.gnu.org
Subject: Re: bug#64253: 26.3; Bug in revert-buffer-with-coding-system
Date: Sat, 01 Jul 2023 11:30:47 +0300
> Cc: 64253 <at> debbugs.gnu.org
> Date: Sat, 24 Jun 2023 11:51:39 +0300
> From: Eli Zaretskii <eliz <at> gnu.org>
> 
> > $ 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.]
> 
> Thanks.  This 21-year old bug (a simple omission of a single code
> line) should now be fixed on the emacs-29 branch.

No further comments, so I assume the bug is indeed fixed, and I'm
closing it.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 29 Jul 2023 11:24:11 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 13 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.