Wrong upload path if remote path doesn't end with "/" #10

Open
opened 2026-09-28 16:16:17 +02:00 by cjohansson · 0 comments
Owner

When setting the variable ssh-deploy-root-local to a string that doesn't end with /, the function ssh-deploy--get-relative-path returns an incorrect path. This is because that function uses replace-regexp-in-string and that regular expression will return the match starting with a /. Then, the function expand-file-name (in line 1148 of ssh-deploy.el) will incorrectly think that it's working with an absolute path and will return the path as given.

This is something that would trigger this problem:

         (ssh-deploy-root-remote . \"/ssh:remote-host:folder/\")
         (ssh-deploy-root-local . \"/home/user/folder\")

Note that in the last example ssh-deploy-root-local doesn't end with a /. Therefore, with that configuration, when deploying something, the deployed file will be incorrectly tried to be placed in the root directory.

When setting the variable `ssh-deploy-root-local` to a string that doesn't end with `/`, the function `ssh-deploy--get-relative-path` returns an incorrect path. This is because that function uses `replace-regexp-in-string` and that regular expression will return the match starting with a `/`. Then, the function `expand-file-name` (in line 1148 of ssh-deploy.el) will incorrectly think that it's working with an absolute path and will return the path as given. This is something that would trigger this problem: ```lisp (ssh-deploy-root-remote . \"/ssh:remote-host:folder/\") (ssh-deploy-root-local . \"/home/user/folder\") ``` Note that in the last example `ssh-deploy-root-local` doesn't end with a `/`. Therefore, with that configuration, when deploying something, the deployed file will be incorrectly tried to be placed in the root directory.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cjohansson/emacs-ssh-deploy#10
No description provided.