summaryrefslogtreecommitdiff
path: root/lisp/url/url-file.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/url/url-file.el')
-rw-r--r--lisp/url/url-file.el41
1 files changed, 22 insertions, 19 deletions
diff --git a/lisp/url/url-file.el b/lisp/url/url-file.el
index 31e5c07234c..a72b2e67a6a 100644
--- a/lisp/url/url-file.el
+++ b/lisp/url/url-file.el
@@ -26,9 +26,14 @@
(require 'mailcap)
(require 'url-vars)
(require 'url-parse)
-(require 'url-dired)
(declare-function mm-disable-multibyte "mm-util" ())
+(defvar url-allow-non-local-files nil
+ "If non-nil, allow URL to fetch non-local files.
+By default, this is not allowed, since that would allow rendering
+HTML to fetch files on other systems if given a <img
+src=\"/ssh:host...\"> element, which can be disturbing.")
+
(defconst url-file-default-port 21 "Default FTP port.")
(defconst url-file-asynchronous-p t "FTP transfers are asynchronous.")
(defalias 'url-file-expand-file-name 'url-default-expander)
@@ -36,10 +41,10 @@
(defun url-file-find-possibly-compressed-file (fname &rest _)
"Find the exact file referenced by `fname'.
This tries the common compression extensions, because things like
-ange-ftp and efs are not quite smart enough to realize when a server
-can do automatic decompression for them, and won't find `foo' if
-`foo.gz' exists, even though the FTP server would happily serve it up
-to them."
+ange-ftp is not quite smart enough to realize when a server can
+do automatic decompression for them, and won't find `foo' if
+`foo.gz' exists, even though the FTP server would happily serve
+it up to them."
(let ((scratch nil)
(compressed-extensions '("" ".gz" ".z" ".Z" ".bz2" ".xz"))
(found nil))
@@ -70,18 +75,15 @@ to them."
buff func
func args
args efs))
- (let ((size (file-attribute-size (file-attributes name))))
- (with-current-buffer buff
- (goto-char (point-max))
- (if (/= -1 size)
- (insert (format "Content-length: %d\n" size)))
- (insert "\n")
- (insert-file-contents-literally name)
- (if (not (url-file-host-is-local-p (url-host url-current-object)))
- (condition-case ()
- (delete-file name)
- (error nil)))
- (apply func args))))
+ (with-current-buffer buff
+ (goto-char (point-max))
+ (insert-file-contents-literally name)
+ (insert (format "Content-length: %d\n\n" (buffer-size)))
+ (if (not (url-file-host-is-local-p (url-host url-current-object)))
+ (condition-case ()
+ (delete-file name)
+ (error nil)))
+ (apply func args)))
(declare-function ange-ftp-set-passwd "ange-ftp" (host user passwd))
(declare-function ange-ftp-copy-file-internal "ange-ftp"
@@ -111,7 +113,8 @@ to them."
(memq system-type '(ms-dos windows-nt)))
(substring file 1))
;; file: URL with a file:/bar:/foo-like spec.
- ((string-match "\\`/[^/]+:/" file)
+ ((and (not url-allow-non-local-files)
+ (string-match "\\`/[^/]+:/" file))
(concat "/:" file))
(t
file))))
@@ -170,7 +173,7 @@ to them."
(if (file-directory-p filename)
;; A directory is done the same whether we are local or remote
- (url-find-file-dired filename)
+ (find-file filename)
(with-current-buffer
(setq buffer (generate-new-buffer " *url-file*"))
(require 'mm-util)