From e906cd0d58f3197edf15ccb843bc2577b879af61 Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Tue, 24 Mar 2020 22:21:26 +0100 Subject: [PATCH] Fix gravatar tests * lisp/image/gravatar.el (gravatar--service-libravatar): Don't error when failing to parse email address, just return the default URL. * test/lisp/image/gravatar-tests.el (gravatar-build-url): Adjust for new default gravatar url. --- lisp/image/gravatar.el | 26 +++++++++++++------------- test/lisp/image/gravatar-tests.el | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lisp/image/gravatar.el b/lisp/image/gravatar.el index e13f0075f3c..ff59a72ac87 100644 --- a/lisp/image/gravatar.el +++ b/lisp/image/gravatar.el @@ -142,19 +142,19 @@ Note that certain services might ignore other options, such as "Find domain that hosts avatars for email address ADDR." ;; implements https://wiki.libravatar.org/api/ (save-match-data - (unless (string-match ".+@\\(.+\\)" addr) - (error "%s is not an email address" addr)) - (let ((domain (match-string 1 addr))) - (catch 'found - (dolist (record '(("_avatars-sec" . "https") - ("_avatars" . "http"))) - (let* ((query (concat (car record) "._tcp." domain)) - (result (dns-query query 'SRV))) - (when result - (throw 'found (format "%s://%s/avatar" - (cdr record) - result))))) - "https://seccdn.libravatar.org/avatar")))) + (if (not (string-match ".+@\\(.+\\)" addr)) + "https://seccdn.libravatar.org/avatar" + (let ((domain (match-string 1 addr))) + (catch 'found + (dolist (record '(("_avatars-sec" . "https") + ("_avatars" . "http"))) + (let* ((query (concat (car record) "._tcp." domain)) + (result (dns-query query 'SRV))) + (when result + (throw 'found (format "%s://%s/avatar" + (cdr record) + result))))) + "https://seccdn.libravatar.org/avatar"))))) (defun gravatar-hash (mail-address) "Return the Gravatar hash for MAIL-ADDRESS." diff --git a/test/lisp/image/gravatar-tests.el b/test/lisp/image/gravatar-tests.el index e66b5c6803d..66098fa0116 100644 --- a/test/lisp/image/gravatar-tests.el +++ b/test/lisp/image/gravatar-tests.el @@ -67,6 +67,6 @@ (gravatar-force-default nil) (gravatar-size nil)) (should (equal (gravatar-build-url "foo") "\ -https://www.gravatar.com/avatar/acbd18db4cc2f85cedef654fccc4a4d8?r=g")))) +https://seccdn.libravatar.org/avatar/acbd18db4cc2f85cedef654fccc4a4d8?r=g")))) ;;; gravatar-tests.el ends here -- 2.39.2