GNU bug report logs -
#55855
"Invalid file name" error with tramp-smb filename check
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your message dated Thu, 09 Jun 2022 18:48:44 +0200
with message-id <87wndphjf7.fsf <at> gmx.de>
and subject line Re: bug#55855: "Invalid file name" error with tramp-smb filename check
has caused the debbugs.gnu.org bug report #55855,
regarding "Invalid file name" error with tramp-smb filename check
to be marked as done.
(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)
--
55855: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=55855
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
[Message part 3 (text/plain, inline)]
So after tramping into an SMB file server, I'm trying to find-file into a
directory whose name is as so: "/smb:username%DOMAIN <at> fsname:/my path/1234.
Some Name". The problem with this filename is that the filename contains a
". ", which throws a tramp-error. And as per the code comment is "not
supported", however it seems as though, at least for the server I'm
connected to, this is supported.
I'm certainly not the most well versed on the samba protocol, but perhaps
look into this and see if the once invalid file names are now valid. Or
perhaps describe specifically what is not supported about this filename.
I'd imagine/assume this is due to a newer SMB version than what the
following code was initially written for.
The following is where the check happens,
```
;; /28.1/lisp/net/tramp-smb.el.gz ;;
(defun tramp-smb-get-localname (vec)
"Return the file name of LOCALNAME.
If VEC has no cifs capabilities, exchange \"/\" by \"\\\\\"."
(save-match-data
(let ((localname (tramp-file-name-unquote-localname vec)))
(setq
localname
(if (string-match "^/?[^/]+\\(/.*\\)" localname)
;; There is a share, separated by "/".
(if (not (tramp-smb-get-cifs-capabilities vec))
(mapconcat
(lambda (x) (if (equal x ?/) "\\" (char-to-string x)))
(match-string 1 localname) "")
(match-string 1 localname))
;; There is just a share.
(if (string-match "^/?\\([^/]+\\)$" localname)
(match-string 1 localname)
"")))
;; Sometimes we have discarded `substitute-in-file-name'.
(when (string-match "\\(\\$\\$\\)\\(/\\|$\\)" localname)
(setq localname (replace-match "$" nil nil localname 1)))
;; A period followed by a space, or trailing periods and spaces,
;; are not supported.
(when (string-match-p "\\. \\|\\.$\\| $" localname) ;; <<<< THIS
CHECK HERE <<<<<
(tramp-error
vec 'file-error
"Invalid file name %s" (tramp-make-tramp-file-name vec localname)))
localname)))
```
My work around for this was to redefine tramp-smb-get-localname with looser
filename checking.
Thanks in advance, and let me know if there's anything else you need from
me.
Cheers,
Evan MacTaggart
[Message part 4 (text/html, inline)]
[Message part 5 (message/rfc822, inline)]
Version: 28.2
Evan MacTaggart <evan.mactaggart <at> gmail.com> writes:
> Hey Michael,
Hi Evan,
> I gave your changes a rip (via the latest emacs-28 branch
> (22a832ad82ed7d099e6ee3a947a5841d84e475c4)) and they worked like a
> charm! I was able to open/save/copy/move/delete both files and
> directories with names containing ". ". Thanks for the speedy response
> and the quick fix, you are awesome!
Thanks for the feedback! I'm closing the bug then.
> Cheers,
> Evan MacTaggart
Best regards, Michael.
This bug report was last modified 2 years and 346 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.