GNU bug report logs - #35448
26.2; save-buffer silently fails in winNT if buffer name has forbidden chars

Previous Next

Package: emacs;

Reported by: Tino Calancha <tino.calancha <at> gmail.com>

Date: Sat, 27 Apr 2019 09:37:01 UTC

Severity: normal

Tags: notabug

Found in version 26.2

Done: Tino Calancha <tino.calancha <at> gmail.com>

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 35448 in the body.
You can then email your comments to 35448 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#35448; Package emacs. (Sat, 27 Apr 2019 09:37:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tino Calancha <tino.calancha <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 27 Apr 2019 09:37:02 GMT) Full text and rfc822 format available.

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

From: Tino Calancha <tino.calancha <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.2; save-buffer silently fails in winNT if buffer name has forbidden
 chars
Date: Sat, 27 Apr 2019 18:36:14 +0900
emacs -Q
;; Do the following recipe in an empty directory

C-x b  schrodinger:cat RET
Miauuuu!!!
C-x C-s RET
;; A message in the minibuffer confirms the name of the file writen to disk.
;; Apparentely, the base name of such a file matches the buffer name.
M-: (file-exists-p buffer-file-name)
=> t
M-: (string= (file-name-nondirectory buffer-file-name) (buffer-name))
=> t


;; In fact, no file matches the buffer name in the directory
M-: (directory-files default-directory nil (buffer-name))
=> nil

;; There is an _empty_ file with name, the buffer name upto the colon
M-: (directory-files default-directory nil "schrod")
=> ("schrodinger")

M-: (with-temp-buffer
      (insert-file-contents "schrodinger")
      (buffer-size))
=> 0

--8<-----------------------------cut here---------------start------------->8---
diff --git a/lisp/files.el b/lisp/files.el
index c05d70a00e..93600d2edb 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -5106,6 +5106,9 @@ basic-save-buffer
                          (expand-file-name
                           (read-file-name "File to save in: "
                                           nil (expand-file-name (buffer-name))))))
+                    (when (and (eq 'windows-nt system-type)
+                               (string-match-p "[:*?\"<>]" (file-name-nondirectory filename)))
+                      (error "A file name cannot contain any of the following characters: :*?\"<>"))
                     (if (file-exists-p filename)
                         (if (file-directory-p filename)
                             ;; Signal an error if the user specified the name of an

--8<-----------------------------cut here---------------end--------------->8---


In GNU Emacs 26.2 (build 1, x86_64-w64-mingw32)
 of 2019-04-13 built on CIRROCUMULUS
Repository revision: fd1b34bfba8f3f6298df47c8e10b61530426f749
Windowing system distributor 'Microsoft Corp.', version 10.0.17763
Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.

Configured using:
 'configure --without-dbus --host=x86_64-w64-mingw32
 --without-compress-install 'CFLAGS=-O2 -static -g3''

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB
TOOLKIT_SCROLL_BARS THREADS LCMS2

Important settings:
  value of $LANG: ENU
  locale-coding-system: cp1252

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny seq byte-opt gv
bytecomp byte-compile cconv cl-loaddefs cl-lib dired dired-loaddefs
format-spec rfc822 mml easymenu mml-sec password-cache epa derived epg
epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils elec-pair time-date
mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel dos-w32 ls-lisp disp-table term/w32-win w32-win
w32-vars term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite charscript charprop case-table epa-hook jka-cmpr-hook
help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote threads w32notify w32 lcms2 multi-tty make-network-process
emacs)

Memory information:
((conses 16 97250 8162)
 (symbols 48 20206 1)
 (miscs 40 40 94)
 (strings 32 29729 1209)
 (string-bytes 1 773709)
 (vectors 16 14066)
 (vector-slots 8 496277 12810)
 (floats 8 51 284)
 (intervals 56 250 17)
 (buffers 992 11))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35448; Package emacs. (Sat, 27 Apr 2019 10:06:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: 35448 <at> debbugs.gnu.org
Subject: Re: bug#35448: 26.2;
 save-buffer silently fails in winNT if buffer name has forbidden chars
Date: Sat, 27 Apr 2019 13:05:05 +0300
> From: Tino Calancha <tino.calancha <at> gmail.com>
> Date: Sat, 27 Apr 2019 18:36:14 +0900
> 
> 
> emacs -Q
> ;; Do the following recipe in an empty directory
> 
> C-x b  schrodinger:cat RET
> Miauuuu!!!
> C-x C-s RET
> ;; A message in the minibuffer confirms the name of the file writen to disk.
> ;; Apparentely, the base name of such a file matches the buffer name.
> M-: (file-exists-p buffer-file-name)
> => t
> M-: (string= (file-name-nondirectory buffer-file-name) (buffer-name))
> => t
> 
> 
> ;; In fact, no file matches the buffer name in the directory
> M-: (directory-files default-directory nil (buffer-name))
> => nil
> 
> ;; There is an _empty_ file with name, the buffer name upto the colon
> M-: (directory-files default-directory nil "schrod")
> => ("schrodinger")

It's a feature.  See

  https://en.wikipedia.org/wiki/NTFS#Alternate_data_streams_(ADS)
  http://www.flexhex.com/docs/articles/alternate-streams.phtml

Whether we should allow this in Emacs is a different matter, but this
was supported since day one, FWIW.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35448; Package emacs. (Sat, 27 Apr 2019 11:15:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: tino.calancha <at> gmail.com
Cc: 35448 <at> debbugs.gnu.org
Subject: Re: bug#35448: 26.2;
 save-buffer silently fails in winNT if buffer name has forbidden chars
Date: Sat, 27 Apr 2019 14:14:35 +0300
> Date: Sat, 27 Apr 2019 13:05:05 +0300
> From: Eli Zaretskii <eliz <at> gnu.org>
> Cc: 35448 <at> debbugs.gnu.org
> 
> > M-: (directory-files default-directory nil "schrod")
> > => ("schrodinger")
> 
> It's a feature.  See
> 
>   https://en.wikipedia.org/wiki/NTFS#Alternate_data_streams_(ADS)
>   http://www.flexhex.com/docs/articles/alternate-streams.phtml

And to see that your cat's meow is not lost, try this:

  C-u M-! streams schrodinger RET




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#35448; Package emacs. (Sat, 27 Apr 2019 11:23:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: tino.calancha <at> gmail.com
Cc: 35448 <at> debbugs.gnu.org
Subject: Re: bug#35448: 26.2;
 save-buffer silently fails in winNT if buffer name has forbidden chars
Date: Sat, 27 Apr 2019 14:22:21 +0300
> Date: Sat, 27 Apr 2019 14:14:35 +0300
> From: Eli Zaretskii <eliz <at> gnu.org>
> Cc: 35448 <at> debbugs.gnu.org
> 
> >   https://en.wikipedia.org/wiki/NTFS#Alternate_data_streams_(ADS)
> >   http://www.flexhex.com/docs/articles/alternate-streams.phtml
> 
> And to see that your cat's meow is not lost, try this:
> 
>   C-u M-! streams schrodinger RET

Even better, kill the buffer and then "C-x C-f schrodinger:cat RET".
(A program such as 'cat' will also show the text.)




Added tag(s) notabug. Request was from Tino Calancha <tino.calancha <at> gmail.com> to control <at> debbugs.gnu.org. (Sat, 04 May 2019 08:24:02 GMT) Full text and rfc822 format available.

Reply sent to Tino Calancha <tino.calancha <at> gmail.com>:
You have taken responsibility. (Sat, 04 May 2019 08:45:02 GMT) Full text and rfc822 format available.

Notification sent to Tino Calancha <tino.calancha <at> gmail.com>:
bug acknowledged by developer. (Sat, 04 May 2019 08:45:02 GMT) Full text and rfc822 format available.

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

From: Tino Calancha <tino.calancha <at> gmail.com>
To: 35448-done <at> debbugs.gnu.org
Subject: Re: bug#35448: 26.2;
 save-buffer silently fails in winNT if buffer name has forbidden chars
Date: Sat, 04 May 2019 17:44:18 +0900
Eli Zaretskii <eliz <at> gnu.org> writes:

I saw the cat meow.
Since this is a feature I wasn't aware of, not a bug, then I am closing this bug.
>> >   https://en.wikipedia.org/wiki/NTFS#Alternate_data_streams_(ADS)
>> >   http://www.flexhex.com/docs/articles/alternate-streams.phtml
>> 
>> And to see that your cat's meow is not lost, try this:
>> 
>>   C-u M-! streams schrodinger RET
>
> Even better, kill the buffer and then "C-x C-f schrodinger:cat RET".
> (A program such as 'cat' will also show the text.)




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

This bug report was last modified 4 years and 325 days ago.

Previous Next


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