emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r100633:


From: Mark A. Hershberger
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r100633:
Date: Tue, 22 Jun 2010 12:57:20 -0400
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 100633 [merge]
committer: Mark A. Hershberger <address@hidden>
branch nick: trunk
timestamp: Tue 2010-06-22 12:57:20 -0400
message:
  
modified:
  lisp/gnus/ChangeLog
  lisp/gnus/mm-url.el
  lisp/url/ChangeLog
  lisp/url/url-parse.el
=== modified file 'lisp/gnus/ChangeLog'
--- a/lisp/gnus/ChangeLog       2010-06-15 20:13:34 +0000
+++ b/lisp/gnus/ChangeLog       2010-06-22 16:48:53 +0000
@@ -1,3 +1,8 @@
+2010-06-22  Mark A. Hershberger  <address@hidden>
+
+       * mm-url.el (mm-url-encode-multipart-form-data): New function to handle
+       the *other* type of HTML form submission.
+
 2010-06-15  Michael Albinus  <address@hidden>
 
        * auth-source.el (auth-source-pick): If choice does not contain a

=== modified file 'lisp/gnus/mm-url.el'
--- a/lisp/gnus/mm-url.el       2010-05-07 06:58:17 +0000
+++ b/lisp/gnus/mm-url.el       2010-06-22 16:48:53 +0000
@@ -418,6 +418,48 @@
             (mm-url-form-encode-xwfu (cdr data))))
    pairs "&"))
 
+(defun mm-url-encode-multipart-form-data (pairs &optional boundary)
+  "Return PAIRS encoded in multipart/form-data."
+  ;; RFC1867
+
+  ;; Get a good boundary
+  (unless boundary
+    (setq boundary (mml-compute-boundary '())))
+
+  (concat
+
+   ;; Start with the boundary
+   "--" boundary "\r\n"
+
+   ;; Create name value pairs
+   (mapconcat
+    'identity
+    ;; Delete any returned items that are empty
+    (delq nil
+          (mapcar (lambda (data)
+            (when (car data)
+              ;; For each pair
+              (concat
+
+               ;; Encode the name
+               "Content-Disposition: form-data; name=\""
+               (car data) "\"\r\n"
+               "Content-Type: text/plain; charset=utf-8\r\n"
+               "Content-Transfer-Encoding: binary\r\n\r\n"
+
+               (cond ((stringp (cdr data))
+                      (cdr data))
+                     ((integerp (cdr data))
+                      (int-to-string (cdr data))))
+
+               "\r\n")))
+                  pairs))
+    ;; use the boundary as a separator
+    (concat "--" boundary "\r\n"))
+
+   ;; put a boundary at the end.
+   "--" boundary "--\r\n"))
+
 (defun mm-url-fetch-form (url pairs)
   "Fetch a form from URL with PAIRS as the data using the POST method."
   (mm-url-load-url)

=== modified file 'lisp/url/ChangeLog'
--- a/lisp/url/ChangeLog        2010-06-16 20:08:41 +0000
+++ b/lisp/url/ChangeLog        2010-06-22 16:48:53 +0000
@@ -1,3 +1,9 @@
+2010-06-22  Mark A. Hershberger  <address@hidden>
+
+       * url-parse.el (url-user-for-url, url-password-for-url):
+       Convenience functions that get usernames and passwords for urls
+       from auth-source functions.
+
 2010-06-12  Štěpán Němec  <address@hidden>  (tiny change)
 
        * url-vars.el (url-privacy-level): Fix doc typo.  (Bug#6406)

=== modified file 'lisp/url/url-parse.el'
--- a/lisp/url/url-parse.el     2010-01-13 08:35:10 +0000
+++ b/lisp/url/url-parse.el     2010-06-22 16:48:53 +0000
@@ -25,6 +25,7 @@
 ;;; Code:
 
 (require 'url-vars)
+(require 'auth-source)
 (eval-when-compile (require 'cl))
 
 (autoload 'url-scheme-get-property "url-methods")
@@ -174,6 +175,25 @@
           (url-parse-make-urlobj
            prot user pass host port file refs attr full)))))))
 
+(defmacro url-bit-for-url (method lookfor url)
+  `(let* ((urlobj (url-generic-parse-url url))
+          (bit (funcall ,method urlobj))
+          (methods (list 'url-recreate-url
+                         'url-host)))
+     (while (and (not bit) (> (length methods) 0))
+       (setq bit
+             (auth-source-user-or-password
+              ,lookfor (funcall (pop methods) urlobj) (url-type urlobj))))
+     bit))
+
+(defun url-user-for-url (url)
+  "Attempt to use .authinfo to find a user for this URL."
+  (url-bit-for-url 'url-user "login" url))
+
+(defun url-password-for-url (url)
+  "Attempt to use .authinfo to find a password for this URL."
+  (url-bit-for-url 'url-password "password" url))
+
 (provide 'url-parse)
 
 ;; arch-tag: f338325f-71ab-4bee-93cc-78fb9a03d403


reply via email to

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