unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Evan MacTaggart <evan.mactaggart@gmail.com>
To: 55855@debbugs.gnu.org
Subject: bug#55855: "Invalid file name" error with tramp-smb filename check
Date: Wed, 8 Jun 2022 11:55:21 -0600	[thread overview]
Message-ID: <CAGLo8Wy1dW7SYBJu1dw3q_5UbQ-m6jjNS1jfYMvFqWRi-KsZhg@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2147 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 2829 bytes --]

             reply	other threads:[~2022-06-08 17:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-08 17:55 Evan MacTaggart [this message]
2022-06-09 12:51 ` bug#55855: "Invalid file name" error with tramp-smb filename check Michael Albinus
2022-06-09 16:24   ` Evan MacTaggart
2022-06-09 16:48     ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGLo8Wy1dW7SYBJu1dw3q_5UbQ-m6jjNS1jfYMvFqWRi-KsZhg@mail.gmail.com \
    --to=evan.mactaggart@gmail.com \
    --cc=55855@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).