From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Evan MacTaggart Newsgroups: gmane.emacs.bugs Subject: bug#55855: "Invalid file name" error with tramp-smb filename check Date: Wed, 8 Jun 2022 11:55:21 -0600 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000005df62905e0f36908" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10829"; mail-complaints-to="usenet@ciao.gmane.io" To: 55855@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 08 20:24:16 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nz0Ln-0002dQ-KK for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 08 Jun 2022 20:24:15 +0200 Original-Received: from localhost ([::1]:51742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nz0Lm-00037p-4x for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 08 Jun 2022 14:24:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57088) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nz0La-00037I-SY for bug-gnu-emacs@gnu.org; Wed, 08 Jun 2022 14:24:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50374) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nz0La-0005tA-Kj for bug-gnu-emacs@gnu.org; Wed, 08 Jun 2022 14:24:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nz0La-0001Cu-FJ for bug-gnu-emacs@gnu.org; Wed, 08 Jun 2022 14:24:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Evan MacTaggart Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 08 Jun 2022 18:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 55855 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16547125824543 (code B ref -1); Wed, 08 Jun 2022 18:24:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 8 Jun 2022 18:23:02 +0000 Original-Received: from localhost ([127.0.0.1]:44268 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nz0Kb-0001At-SK for submit@debbugs.gnu.org; Wed, 08 Jun 2022 14:23:02 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:43496) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nyzu5-0000T9-Fl for submit@debbugs.gnu.org; Wed, 08 Jun 2022 13:55:37 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyzu5-0007AL-6R for bug-gnu-emacs@gnu.org; Wed, 08 Jun 2022 13:55:37 -0400 Original-Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]:36809) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nyzu3-0001a6-En for bug-gnu-emacs@gnu.org; Wed, 08 Jun 2022 13:55:36 -0400 Original-Received: by mail-lf1-x132.google.com with SMTP id i29so17615544lfp.3 for ; Wed, 08 Jun 2022 10:55:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=0iqmSDj07b0EBDpmtKLs5Z+2scAaqCGZfHcqrjMmaFg=; b=lJCsdffOfUr7St8olEn/t08YkESbdZM8U96h60A8VnwZjD8Lme1qe3ON/zb8vUdqTd /7PZh24/AxMhiWhpNWDybmWhmbfWsflsX/Jcdv/xIjSRNnw9Qt10FPxLOQArvhU8ydy5 Loqu8gGkDW+v+gkAmMJ1AJWTS7Y3OR9d9M0Z5V4DK4qXR0dPj36Mvh9JlEVMFQzp65n0 A1l9ao8SgPoz1UJdk/OhoqMpR1+yIUF2Kp5V0VyPiXrSf+zNQJHwGMokjVyOPQsIqE+F 9tm2rvB148BaC/Kfd/9RrDDjb5lqlqmPFiFcUJIBWCg5xfkU0In7GUFzFsSpINY0YeYn H+Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=0iqmSDj07b0EBDpmtKLs5Z+2scAaqCGZfHcqrjMmaFg=; b=t3LywCTIBPZHECnDiRDtrbYojqAwjoYHELVrwGoLur4XTZcsXDcHklgPKNuLfE/i2r FuIHKGqqBprguaoOFCgjBXunI44vweSuXN7wrwCx2r7njA3Yl2fm8zJu0Rf/2UpC0jra 7KHMOCBkN12vKDgnF74B0Pz85EDEsd3jQ3CunQI0Lk4R5wdaC1XXmKhc3RNk3xiCCrAM M3jCVtuA6h/Zy3l9S93bZoPaj6wUoFUkf6z+1v5A5SHY7+0RSsqqzuZTzDcYkPacL+R5 B7+grRTHhwPNuwmKjMV2/v5RU+D7xAEvxp25xXxPX6sWhyTmqzWSeNPjCk+YzQbXqOo0 xXEA== X-Gm-Message-State: AOAM533Nj8MS+WsFDW/BNyFQQLaZTG1PjuyZt/eCv3ayCOBg+djQxek0 eD4fkJjJtlI1S8OxF2FsaoHzVweFXXuEZ88CwzIeWMDkoMyAuQ== X-Google-Smtp-Source: ABdhPJx3Ownn3ejE1JOGDDoDABqVBHKz3RGecKLuCuTqUwvGa4z/etmPIBXdF3TWGobgXcENjjTgbIIgYHAjWYAwru4= X-Received: by 2002:a19:6445:0:b0:479:141c:cb5b with SMTP id b5-20020a196445000000b00479141ccb5bmr20210833lfj.280.1654710932992; Wed, 08 Jun 2022 10:55:32 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::132; envelope-from=evan.mactaggart@gmail.com; helo=mail-lf1-x132.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 08 Jun 2022 14:23:00 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:233992 Archived-At: --0000000000005df62905e0f36908 Content-Type: text/plain; charset="UTF-8" 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 --0000000000005df62905e0f36908 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
So after tramping into an SMB file server, I'm tr= ying to find-file into a directory whose name is as so: "/smb:username= %DOMAIN@fsname:/my path/1234. Some Name".=C2=A0 The problem with this = filename is that the filename contains a ". ", which throws a tra= mp-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 supporte= d about this filename. I'd imagine/assume this is due to a newer SMB ve= rsion 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)
=C2=A0 "Return the file name of LOCALNAME.=
If VEC has no cifs capabilities, exchange \"/\" by \"\\\= \\"."
=C2=A0 (save-match-data
=C2=A0 =C2=A0 (let ((localnam= e (tramp-file-name-unquote-localname vec)))
=C2=A0 =C2=A0 =C2=A0 (setq=C2=A0 =C2=A0 =C2=A0 =C2=A0localname
=C2=A0 =C2=A0 =C2=A0 =C2=A0(if (s= tring-match "^/?[^/]+\\(/.*\\)" localname)
=C2=A0 ;; There i= s a share, separated by "/".
=C2=A0 (if (not (tramp-smb-get-= cifs-capabilities vec))
=C2=A0 =C2=A0 =C2=A0 (mapconcat
(lambda (= x) (if (equal x ?/) "\\" (char-to-string x)))
(match-string = 1 localname) "")
=C2=A0 =C2=A0 (match-string 1 localname)) ;; There is just a share.
(if (string-match "^/?\\([^/]+\\)$&= quot; localname)
=C2=A0 =C2=A0 (match-string 1 localname)
=C2=A0 = "")))

=C2=A0 =C2=A0 =C2=A0 ;; Sometimes we have discarded = `substitute-in-file-name'.
=C2=A0 =C2=A0 =C2=A0 (when (string-match = "\\(\\$\\$\\)\\(/\\|$\\)" localname)
(setq localname (replace= -match "$" nil nil localname 1)))

=C2=A0 =C2=A0 =C2=A0 ;; = A period followed by a space, or trailing periods and spaces,
=C2=A0 =C2= =A0 =C2=A0 ;; are not supported.
=C2=A0 =C2=A0 =C2=A0 (when (string-matc= h-p "\\. \\|\\.$\\| $" localname) ;; <<<< THIS CHECK = HERE <<<<<
(tramp-error
vec 'file-error
&q= uot;Invalid file name %s" (tramp-make-tramp-file-name vec localname)))=

=C2=A0 =C2=A0 =C2=A0 localname)))
```

My work = around for this was to redefine tramp-smb-get-localname with looser filenam= e checking.

Thanks in advance, and let me know if there&= #39;s anything else you need from me.

Cheers,
Evan MacTaggart
--0000000000005df62905e0f36908--