Subject: bug#35448: closed (Re: bug#35448: 26.2; save-buffer silently fails in winNT if buffer name has forbidden chars)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 04 May 2019 08:45:02 +0000

Your bug report

#35448: 26.2; save-buffer silently fails in winNT if buffer name has forbidden chars

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
35448: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=35448
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#35448: 26.2; save-buffer silently fails in winNT if buffer name has forbidden chars
From: Tino Calancha <[email-masked]>
To: [email-masked]
Date: Sat, 04 May 2019 17:44:18 +0900
List-Id: <debbugs-submit.debbugs.gnu.org>

Eli Zaretskii <[email-masked]> 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.)

Subject: 26.2; save-buffer silently fails in winNT if buffer name has forbidden chars
From: Tino Calancha <[email-masked]>
To: [email-masked]
Date: Sat, 27 Apr 2019 18:36:14 +0900
List-Id: <debbugs-submit.debbugs.gnu.org>

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))