]> code.delx.au - gnu-emacs/blobdiff - lisp/gnus/smime.el
Merge from origin/emacs-25
[gnu-emacs] / lisp / gnus / smime.el
index 76d58f773543991c72a990137b82e2100a71017d..44841a7142277fd58729cddab778762dc3bb3368 100644 (file)
@@ -1,6 +1,6 @@
 ;;; smime.el --- S/MIME support library
 
-;; Copyright (C) 2000-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2016 Free Software Foundation, Inc.
 
 ;; Author: Simon Josefsson <simon@josefsson.org>
 ;; Keywords: SMIME X.509 PEM OpenSSL
 
 (eval-when-compile (require 'cl))
 
-(eval-and-compile
-  (cond
-   ((fboundp 'replace-in-string)
-    (defalias 'smime-replace-in-string 'replace-in-string))
-   ((fboundp 'replace-regexp-in-string)
-    (defun smime-replace-in-string  (string regexp newtext &optional literal)
-      "Replace all matches for REGEXP with NEWTEXT in STRING.
-If LITERAL is non-nil, insert NEWTEXT literally.  Return a new
-string containing the replacements.
-
-This is a compatibility function for different Emacsen."
-      (replace-regexp-in-string regexp newtext string nil literal)))))
-
 (defgroup smime nil
   "S/MIME configuration."
   :group 'mime)
@@ -244,18 +231,6 @@ must be set in `ldap-host-parameters-alist'."
 
 (defvar smime-details-buffer "*OpenSSL output*")
 
-;; Use mm-util?
-(eval-and-compile
-  (defalias 'smime-make-temp-file
-    (if (fboundp 'make-temp-file)
-       'make-temp-file
-      (lambda (prefix &optional dir-flag) ;; Simple implementation
-       (expand-file-name
-        (make-temp-name prefix)
-        (if (fboundp 'temp-directory)
-            (temp-directory)
-          temporary-file-directory))))))
-
 ;; Password dialog function
 (declare-function password-read-and-add "password-cache" (prompt &optional key))
 
@@ -301,7 +276,7 @@ key and certificate itself."
         (keyfile (or (car-safe keyfile) keyfile))
         (buffer (generate-new-buffer " *smime*"))
         (passphrase (smime-ask-passphrase (expand-file-name keyfile)))
-        (tmpfile (smime-make-temp-file "smime")))
+        (tmpfile (make-temp-file "smime")))
     (if passphrase
        (setenv "GNUS_SMIME_PASSPHRASE" passphrase))
     (prog1
@@ -335,7 +310,7 @@ have proper MIME tags.  CERTFILES is a list of filenames, each file
 is expected to contain of a PEM encoded certificate."
   (smime-new-details-buffer)
   (let ((buffer (generate-new-buffer " *smime*"))
-       (tmpfile (smime-make-temp-file "smime")))
+       (tmpfile (make-temp-file "smime")))
     (prog1
        (when (prog1
                  (apply 'smime-call-openssl-region b e (list buffer tmpfile)
@@ -431,7 +406,7 @@ in the buffer specified by `smime-details-buffer'."
   (smime-new-details-buffer)
   (let ((buffer (generate-new-buffer " *smime*"))
        CAs (passphrase (smime-ask-passphrase (expand-file-name keyfile)))
-       (tmpfile (smime-make-temp-file "smime")))
+       (tmpfile (make-temp-file "smime")))
     (if passphrase
        (setenv "GNUS_SMIME_PASSPHRASE" passphrase))
     (if (prog1
@@ -588,13 +563,9 @@ A string or a list of strings is returned."
   "Get certificate for MAIL from the ldap server at HOST."
   (let ((ldapresult
         (funcall
-         (if (featurep 'xemacs)
-             (progn
-               (require 'smime-ldap)
-               'smime-ldap-search)
-           (progn
-             (require 'ldap)
-             'ldap-search))
+         (progn
+           (require 'ldap)
+           'ldap-search)
          (concat "mail=" mail)
          host '("userCertificate") nil))
        (retbuf (generate-new-buffer (format "*certificate for %s*" mail)))
@@ -611,11 +582,11 @@ A string or a list of strings is returned."
                  (string= (substring (cadaar ldapresult) 0 3)
                           "MII"))
              (setq cert
-                   (smime-replace-in-string
-                    (cadaar ldapresult)
+                   (replace-regexp-in-string
                     (concat "\\(\n\\|\r\\|-----BEGIN CERTIFICATE-----\\|"
                             "-----END CERTIFICATE-----\\)")
-                    "" t))
+                    ""
+                    (cadaar ldapresult) nil t))
            (setq cert (base64-encode-string (cadaar ldapresult) t)))
          (insert "-----BEGIN CERTIFICATE-----\n")
          (let ((i 0) (len (length cert)))