lang/org: fix attachments getting double-url-encoded when exported
This commit is contained in:
parent
318f51cfff
commit
ae031928af
1 changed files with 16 additions and 15 deletions
|
@ -83,21 +83,22 @@ the cursor."
|
||||||
(unless (eq major-mode 'org-mode)
|
(unless (eq major-mode 'org-mode)
|
||||||
(user-error "Not in an org buffer"))
|
(user-error "Not in an org buffer"))
|
||||||
(require 'org-download)
|
(require 'org-download)
|
||||||
(condition-case ex
|
(let ((raw-uri (url-unhex-string uri)))
|
||||||
(cond ((string-match-p "^data:image/png;base64," uri)
|
(condition-case ex
|
||||||
(org-download-dnd-base64 uri nil))
|
(cond ((string-match-p "^data:image/png;base64," uri)
|
||||||
((image-type-from-file-name uri)
|
(org-download-dnd-base64 uri nil))
|
||||||
(org-download-image uri))
|
((image-type-from-file-name raw-uri)
|
||||||
(t
|
(org-download-image raw-uri))
|
||||||
(let ((new-path (expand-file-name (org-download--fullname uri))))
|
(t
|
||||||
;; Download the file
|
(let ((new-path (expand-file-name (org-download--fullname raw-uri))))
|
||||||
(if (string-match-p (concat "^" (regexp-opt '("http" "https" "nfs" "ftp" "file")) ":/") uri)
|
;; Download the file
|
||||||
(url-copy-file uri new-path)
|
(if (string-match-p (concat "^" (regexp-opt '("http" "https" "nfs" "ftp" "file")) ":/") uri)
|
||||||
(copy-file uri new-path))
|
(url-copy-file raw-uri new-path)
|
||||||
;; insert the link
|
(copy-file uri new-path))
|
||||||
(org-download-insert-link uri new-path))))
|
;; insert the link
|
||||||
(error
|
(org-download-insert-link raw-uri new-path))))
|
||||||
(user-error "Failed to attach file: %s" (error-message-string ex)))))
|
(error
|
||||||
|
(user-error "Failed to attach file: %s" (error-message-string ex))))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +org-attach-download-dnd (uri action)
|
(defun +org-attach-download-dnd (uri action)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue