emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org 3dbeb67 1/3: test-org-protocol.el: Add expected fai


From: ELPA Syncer
Subject: [elpa] externals/org 3dbeb67 1/3: test-org-protocol.el: Add expected failures for file:/// URLs
Date: Wed, 28 Apr 2021 03:57:19 -0400 (EDT)

branch: externals/org
commit 3dbeb677e00b363842ade60036e0f225d43f568d
Author: Maxim Nikulin <manikulin@gmail.com>
Commit: Bastien Guerry <bzg@gnu.org>

    test-org-protocol.el: Add expected failures for file:/// URLs
    
    * testing/lisp/test-org-protocol.el
    (test-org-protocol/org-protocol-store-link-file,
    test-org-protocol/org-protocol-capture-file): Add tests to document
    that existing calls to `org-protocol-sanitize-uri' could make passed
    URLs invalid by changing number of slashes after scheme.
    
    Till a fix of the problem the new tests are marked as expected failures.
    
    Unless a relatively recent commit 5748615c48, I would believe that
    `org-protocol-sanitize-uri' was added by mistake to the initial
    implementation.  Capture URLs are anyway escaped with percent encoding.
---
 testing/lisp/test-org-protocol.el | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/testing/lisp/test-org-protocol.el 
b/testing/lisp/test-org-protocol.el
index b5df7c1..b9db8fd 100644
--- a/testing/lisp/test-org-protocol.el
+++ b/testing/lisp/test-org-protocol.el
@@ -78,6 +78,16 @@
     (should (null (org-protocol-check-filename-for-protocol uri (list uri) 
nil)))
     (should (equal (car org-stored-links) '("URL3" "TITLE3")))))
 
+(ert-deftest test-org-protocol/org-protocol-store-link-file ()
+  "store-link: `org-protocol-sanitize-uri' could distort URL."
+  :expected-result :failed
+  (let ((uri 
"/org-protocol:/store-link:/file%3A%2F%2F%2Fetc%2Fmailcap/Triple%20Slash"))
+    (should (null (org-protocol-check-filename-for-protocol uri (list uri) 
nil)))
+    (should (equal (car org-stored-links) '("file:///etc/mailcap" "Triple 
Slash"))))
+  (let ((uri 
"/org-protocol:/store-link?url=file%3A%2F%2F%2Fetc%2Fmailcap&title=Triple%20Slash"))
+    (should (null (org-protocol-check-filename-for-protocol uri (list uri) 
nil)))
+    (should (equal (car org-stored-links) '("file:///etc/mailcap" "Triple 
Slash")))))
+
 (ert-deftest test-org-protocol/org-protocol-capture ()
   "Test `org-protocol-capture' specifications."
   (let* ((org-protocol-default-template-key "t")
@@ -134,6 +144,20 @@
      test-urls)
     (delete-file temp-file-name)))
 
+(ert-deftest test-org-protocol/org-protocol-capture-file ()
+  "capture: `org-protocol-sanitize-uri' could distort URL."
+  :expected-result :failed
+  (let* ((org-protocol-default-template-key "t")
+        (temp-file-name (make-temp-file "org-protocol-test"))
+        (org-capture-templates
+         `(("t" "Test" plain (file ,temp-file-name) "%a\n%i\n" :kill-buffer 
t))))
+    (let ((uri 
"/org-protocol:/capture:/t/file%3A%2F%2F%2Fetc%2Fmailcap/Triple%20Slash/Body"))
+      (should (null (org-protocol-check-filename-for-protocol uri (list uri) 
nil)))
+      (should (string= (buffer-string) "[[file:///etc/mailcap][Triple 
Slash]]\nBody")))
+    (let ((uri 
"/org-protocol:/capture?template=t&url=file%3A%2F%2F%2Fetc%2Fmailcap&title=Triple%20Slash&body=Body"))
+      (should (null (org-protocol-check-filename-for-protocol uri (list uri) 
nil)))
+      (should (string= (buffer-string) "[[file:///etc/mailcap][Triple 
Slash]]\nBody")))))
+
 (ert-deftest test-org-protocol/org-protocol-open-source ()
   "Test org-protocol://open-source links."
   (let* ((temp-file-name1 (make-temp-file "org-protocol-test1"))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]