diff options
| author | Stefan Monnier | 2006-03-29 08:00:09 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2006-03-29 08:00:09 +0000 |
| commit | bdba217b303242c4556aec783fbb080092458a1d (patch) | |
| tree | ec276118383307bbec49ab11a7c5c66ff4fb67bd | |
| parent | 29314e0fd78063d663bd272787d0ea81cc61e38e (diff) | |
| download | emacs-bdba217b303242c4556aec783fbb080092458a1d.tar.gz emacs-bdba217b303242c4556aec783fbb080092458a1d.zip | |
(url-handler-directory-file-name): New handler.
(url-file-local-copy): Plug race condition security hole.
| -rw-r--r-- | lisp/url/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/url/url-handlers.el | 21 |
2 files changed, 25 insertions, 1 deletions
diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog index e7e358bb894..7d9e289e8e5 100644 --- a/lisp/url/ChangeLog +++ b/lisp/url/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2006-03-29 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * url-handlers.el (url-handler-directory-file-name): New handler. | ||
| 4 | (url-file-local-copy): Plug race condition security hole. | ||
| 5 | |||
| 1 | 2006-03-27 Romain Francoise <romain@orebokech.com> | 6 | 2006-03-27 Romain Francoise <romain@orebokech.com> |
| 2 | 7 | ||
| 3 | * url-irc.el (url-irc-rcirc, url-irc-erc): New functions. | 8 | * url-irc.el (url-irc-rcirc, url-irc-erc): New functions. |
diff --git a/lisp/url/url-handlers.el b/lisp/url/url-handlers.el index 0338eefd268..00fc415659e 100644 --- a/lisp/url/url-handlers.el +++ b/lisp/url/url-handlers.el | |||
| @@ -151,6 +151,8 @@ the arguments that would have been passed to OPERATION." | |||
| 151 | (put 'substitute-in-file-name 'url-file-handlers 'url-file-handler-identity) | 151 | (put 'substitute-in-file-name 'url-file-handlers 'url-file-handler-identity) |
| 152 | (put 'file-name-absolute-p 'url-file-handlers (lambda (&rest ignored) t)) | 152 | (put 'file-name-absolute-p 'url-file-handlers (lambda (&rest ignored) t)) |
| 153 | (put 'expand-file-name 'url-file-handlers 'url-handler-expand-file-name) | 153 | (put 'expand-file-name 'url-file-handlers 'url-handler-expand-file-name) |
| 154 | (put 'directory-file-name 'url-file-handlers 'url-handler-directory-file-name) | ||
| 155 | ;; (put 'file-name-as-directory 'url-file-handlers 'url-handler-file-name-as-directory) | ||
| 154 | 156 | ||
| 155 | ;; These are operations that we do not support yet (DAV!!!) | 157 | ;; These are operations that we do not support yet (DAV!!!) |
| 156 | (put 'file-writable-p 'url-file-handlers 'ignore) | 158 | (put 'file-writable-p 'url-file-handlers 'ignore) |
| @@ -160,10 +162,27 @@ the arguments that would have been passed to OPERATION." | |||
| 160 | (put 'vc-registered 'url-file-handlers 'ignore) | 162 | (put 'vc-registered 'url-file-handlers 'ignore) |
| 161 | 163 | ||
| 162 | (defun url-handler-expand-file-name (file &optional base) | 164 | (defun url-handler-expand-file-name (file &optional base) |
| 165 | ;; When we see "/foo/bar" in a file whose working dir is "http://bla/bla", | ||
| 166 | ;; there are two interpretations possible: either it's a local "/foo/bar" | ||
| 167 | ;; or it's "http:/bla/foo/bar". When working with URLs, the second | ||
| 168 | ;; interpretation is the right one, but when working with Emacs file | ||
| 169 | ;; names, the first is preferred. | ||
| 163 | (if (file-name-absolute-p file) | 170 | (if (file-name-absolute-p file) |
| 164 | (expand-file-name file "/") | 171 | (expand-file-name file "/") |
| 165 | (url-expand-file-name file base))) | 172 | (url-expand-file-name file base))) |
| 166 | 173 | ||
| 174 | ;; directory-file-name and file-name-as-directory are kind of hard to | ||
| 175 | ;; implement really right for URLs since URLs can have repeated / chars. | ||
| 176 | ;; We'd want the following behavior: | ||
| 177 | ;; idempotence: (d-f-n (d-f-n X) == (d-f-n X) | ||
| 178 | ;; idempotence: (f-n-a-d (f-n-a-d X) == (f-n-a-d X) | ||
| 179 | ;; reversible: (d-f-n (f-n-a-d (d-f-n X))) == (d-f-n X) | ||
| 180 | ;; reversible: (f-n-a-d (d-f-n (f-n-a-d X))) == (f-n-a-d X) | ||
| 181 | (defun url-handler-directory-file-name (dir) | ||
| 182 | ;; When there's more than a single /, just don't touch the slashes at all. | ||
| 183 | (if (string-match "//\\'" dir) dir | ||
| 184 | (url-run-real-handler 'directory-file-name (list dir)))) | ||
| 185 | |||
| 167 | ;; The actual implementation | 186 | ;; The actual implementation |
| 168 | ;;;###autoload | 187 | ;;;###autoload |
| 169 | (defun url-copy-file (url newname &optional ok-if-already-exists keep-time) | 188 | (defun url-copy-file (url newname &optional ok-if-already-exists keep-time) |
| @@ -193,7 +212,7 @@ A prefix arg makes KEEP-TIME non-nil." | |||
| 193 | "Copy URL into a temporary file on this machine. | 212 | "Copy URL into a temporary file on this machine. |
| 194 | Returns the name of the local copy, or nil, if FILE is directly | 213 | Returns the name of the local copy, or nil, if FILE is directly |
| 195 | accessible." | 214 | accessible." |
| 196 | (let ((filename (make-temp-name "url"))) | 215 | (let ((filename (make-temp-file "url"))) |
| 197 | (url-copy-file url filename) | 216 | (url-copy-file url filename) |
| 198 | filename)) | 217 | filename)) |
| 199 | 218 | ||