From: Kenjiro NAKAYAMA <nakayamakenjiro@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: Kenjiro NAKAYAMA <nakayamakenjiro@gmail.com>, 16198@debbugs.gnu.org
Subject: bug#16198: 24.3.50; [PATCH 1/2] eww: Does not support file upload.
Date: Wed, 25 Dec 2013 13:29:29 +0900 [thread overview]
Message-ID: <87ob457due.fsf@dhcp-193-97.nrt.redhat.com> (raw)
In-Reply-To: <87ha9yzot3.fsf@building.gnus.org>
> This is not the Emacs parenthesis style. All the closing parentheses
> should be on the same line. And there's a superfluous `concat' there...
Thank you Lars and Ted,
Since I fixed the patches, I send again.
Signed-off-by: Kenjiro NAKAYAMA <nakayamakenjiro@gmail.com>
* gnus/mm-url.el (mm-url-encode-multipart-form-data):
Restore to handle "maltipart/form-data" by eww.
* net/eww.el(eww-form-file(defface)): New defface of file upload form.
(eww-submit-file): New key map of file upload.
(eww-form-file): New file upload button and file name context.
(eww-select-file): Select file and display selected file name.
(eww-tag-input): Handle input tag of file type.
(eww-update-field): Add point offset.
(eww-submit): Add submit with multipart/form-data.
---
lisp/gnus/mm-url.el | 45 +++++++++++++++++++++++--
lisp/net/eww.el | 97 +++++++++++++++++++++++++++++++++++++++++++++--------
2 files changed, 126 insertions(+), 16 deletions(-)
diff --git a/lisp/gnus/mm-url.el b/lisp/gnus/mm-url.el
index 6e83b18..9deb160 100644
--- a/lisp/gnus/mm-url.el
+++ b/lisp/gnus/mm-url.el
@@ -416,13 +416,54 @@ spaces. Die Die Die."
(autoload 'mml-compute-boundary "mml")
+(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)
+ (cond ((equal (car data) "file")
+ ;; For each pair
+ (concat
+ ;; Encode the name
+ "Content-Disposition: form-data; name=\"" (cdr (assoc "name" (cdr data))) "\"; filename=\"" (cdr (assoc "filename" (cdr data))) "\"\r\n"
+ "Content-Type: text/plain; charset=utf-8\r\n"
+ "Content-Transfer-Encoding: binary\r\n\r\n"
+ (cond ((stringp (cdr (assoc "filedata" (cdr data))))
+ (cdr (assoc "filedata" (cdr data))))
+ ((integerp (cdr (assoc "filedata" (cdr data))))
+ (int-to-string (cdr (assoc "filedata" (cdr data))))))
+ "\r\n"))
+ ((equal (car data) "submit")
+ (concat
+ "Content-Disposition: form-data; name=\"submit\"\r\n\r\n"
+ "Submit"))
+ (t
+ (concat
+ "Content-Disposition: form-data;name=" (car data) "\r\n\r\n"
+ (mm-url-form-encode-xwfu (cdr data))))))
+ pairs))
+ ;; use the boundary as a separator
+ (concat "\r\n--" boundary "\r\n"))
+ ;; put a boundary at the end.
+ "--" boundary "--\r\n"))
+
(defun mm-url-remove-markup ()
"Remove all HTML markup, leaving just plain text."
(goto-char (point-min))
(while (search-forward "<!--" nil t)
(delete-region (match-beginning 0)
- (or (search-forward "-->" nil t)
- (point-max))))
+ (or (search-forward "-->" nil t)
+ (point-max))))
(goto-char (point-min))
(while (re-search-forward "<[^>]+>" nil t)
(replace-match "" t t)))
--- [1/2] ---
larsi@gnus.org writes:
> Kenjiro NAKAYAMA <nakayamakenjiro@gmail.com> writes:
>
>> This report includes a patch to eww file upload. Please, review and
>> install it to the official tree if appreciated.
>
> It sounds like useful functionality, but Emacs went into feature freeze
> yesterday, so it'll have to wait until Emacs thaws again.
>
> Comment about the code:
>
>> + (concat
>> + "Content-Disposition: form-data;name=" (car data) "\r\n\r\n"
>> + (concat (mm-url-form-encode-xwfu (cdr data))
>> + )))
>> + ))
>
> This is not the Emacs parenthesis style. All the closing parentheses
> should be on the same line. And there's a superfluous `concat' there...
next prev parent reply other threads:[~2013-12-25 4:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-20 9:29 bug#16198: 24.3.50; [PATCH 1/2] eww: Does not support file upload Kenjiro NAKAYAMA
2013-12-21 20:27 ` Ted Zlatanov
2013-12-24 7:32 ` Lars Ingebrigtsen
2013-12-25 4:29 ` Kenjiro NAKAYAMA [this message]
2013-12-25 8:26 ` Lars Ingebrigtsen
2013-12-25 15:09 ` Kenjiro NAKAYAMA
2014-11-10 21:34 ` Lars Magne Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ob457due.fsf@dhcp-193-97.nrt.redhat.com \
--to=nakayamakenjiro@gmail.com \
--cc=16198@debbugs.gnu.org \
--cc=larsi@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.