branch: externals/plz commit f7357edb4e4111a3d602c21185f319772e831229 Merge: 5008920318 c579f039ff Author: Adam Porter <a...@alphapapa.net> Commit: Adam Porter <a...@alphapapa.net>
Merge: v0.9.1 --- README.org | 8 +++++++- plz.el | 15 +++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/README.org b/README.org index 5e40920a33..3181c1c58e 100644 --- a/README.org +++ b/README.org @@ -125,7 +125,7 @@ Synchronously download a JPEG file, then create an Emacs image object from the d - ~string~ to pass the response body as a decoded string. - ~response~ to pass a ~plz-response~ structure. - ~file~ to pass a temporary filename to which the response body has been saved without decoding. - - ~(file ~FILENAME)~ to pass ~FILENAME~ after having saved the response body to it without decoding. ~FILENAME~ must be a non-existent file; if it exists, it will not be overwritten, and an error will be signaled. + - ~(file ~FILENAME)~ to pass ~FILENAME~ after having saved the response body to it without decoding. ~FILENAME~ must be a non-existent file; if it exists, it will not be overwritten, and an error will be signaled. ~FILENAME~ is passed through ~expand-file-name~, which see. - A function, which is called in the response buffer with it narrowed to the response body (suitable for, e.g. ~json-read~). If ~DECODE~ is non-nil, the response body is decoded automatically. For binary content, it should be nil. When ~AS~ is ~binary~, ~DECODE~ is automatically set to nil. @@ -192,6 +192,12 @@ You may also clear a queue with ~plz-clear~, which cancels any active or queued Nothing new yet. +** 0.9.1 + +*Fixes* + ++ Expand filenames when downloading to files (which was already applied to filenames passed for uploading). (Thanks to [[https://github.com/josephmturner][Joseph Turner]].) + ** 0.9 *Compatibility* diff --git a/plz.el b/plz.el index 7d5246ca5d..c3316dd481 100644 --- a/plz.el +++ b/plz.el @@ -359,7 +359,8 @@ It may be: - `(file FILENAME)' to pass FILENAME after having saved the response body to it without decoding. FILENAME must be a non-existent file; if it exists, it will not be overwritten, - and an error will be signaled. + and an error will be signaled. FILENAME is passed through + `expand-file-name', which see. - A function, which is called in the response buffer with it narrowed to the response body (suitable for, e.g. `json-read'). @@ -454,7 +455,9 @@ into the process buffer. (`(file ,(and (pred stringp) as-filename)) (when (file-exists-p as-filename) (error "File exists, will not overwrite: %S" as-filename)) - (setf filename as-filename) + ;; Use `expand-file-name' because curl doesn't + ;; expand, e.g. "~" into "/home/...". + (setf filename (expand-file-name as-filename)) (list (cons "--output" filename)))))) ((or 'put 'post) (append (list (cons "--dump-header" "-") @@ -466,7 +469,9 @@ into the process buffer. (`(file ,(and (pred stringp) as-filename)) (when (file-exists-p as-filename) (error "File exists, will not overwrite: %S" as-filename)) - (setf filename as-filename) + ;; Use `expand-file-name' because curl doesn't + ;; expand, e.g. "~" into "/home/...". + (setf filename (expand-file-name as-filename)) (list (cons "--output" filename)))) (list ;; It appears that this must be the last argument @@ -487,7 +492,9 @@ into the process buffer. (`(file ,(and (pred stringp) as-filename)) (when (file-exists-p as-filename) (error "File exists, will not overwrite: %S" as-filename)) - (setf filename as-filename) + ;; Use `expand-file-name' because curl doesn't + ;; expand, e.g. "~" into "/home/...". + (setf filename (expand-file-name as-filename)) (list (cons "--output" filename)))))) ('head (list (cons "--head" "")