Subject: Re: bug#55855: "Invalid file name" error with tramp-smb filename check

From: Michael Albinus <[email-masked]>
Date: Thu, 09 Jun 2022 14:51:00 +0200

Evan MacTaggart <[email-masked]> writes:

Hi Evan,

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

Thanks for the report and the analysis!

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

I've digged into this, and you are right: There is no SMB protocol
problem. There is an error in tramp-smb-handle-write-region, which
didn't quote tmpfile when sending "put ...". Since it wasn't detected
earlier, it was regarded as problem of SMB, resulting in the wrong
check.

I've fixed this now, and I've also adapted the check in
tramp-smb-get-localname. Pushed to the emacs-28 git branch. Will appear
with Emacs 28.2 as well as with the next GNU ELPA Tramp release (2.5.3
or 2.6.0, not decided yet).

> Thanks in advance, and let me know if there's anything else you need
> from me.

You could test with the emacs-28 git branch. For the master branch, I
haven't pushed a fix yet, because I'd like to rework it for being more
robust. If you don't use a git clone, you can consult the patch at
<https://git.savannah.gnu.org/cgit/emacs.git/commit/?h=emacs-28&id=3fd08543782d0d417eaa2dda0727ea16b3271710>. Does
it work for you as well?

> Cheers,
> Evan MacTaggart

Best regards, Michael.