From: Robert Pluim Date: Tue, 24 Mar 2020 21:21:26 +0000 (+0100) Subject: Fix gravatar tests X-Git-Tag: emacs-28.0.90~7726^2~1 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e906cd0d58f3197edf15ccb843bc2577b879af61;p=emacs.git 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. --- 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