From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kenjiro NAKAYAMA Newsgroups: gmane.emacs.bugs Subject: bug#16198: 24.3.50; [PATCH 1/2] eww: Does not support file upload. Date: Thu, 26 Dec 2013 00:09:20 +0900 Message-ID: <874n5x7ysf.fsf@dhcp-193-97.nrt.redhat.com> References: <87fvpnzx8e.fsf@dhcp-193-97.nrt.redhat.com> <87ha9yzot3.fsf@building.gnus.org> <87ob457due.fsf@dhcp-193-97.nrt.redhat.com> <87r491l4ki.fsf@building.gnus.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1387984222 16118 80.91.229.3 (25 Dec 2013 15:10:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 25 Dec 2013 15:10:22 +0000 (UTC) Cc: Kenjiro NAKAYAMA , 16198@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Dec 25 16:10:24 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Vvq6H-0002sy-8m for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 Dec 2013 16:10:21 +0100 Original-Received: from localhost ([::1]:42681 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vvq6G-0006Zt-CW for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 Dec 2013 10:10:20 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56707) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vvq66-0006Za-It for bug-gnu-emacs@gnu.org; Wed, 25 Dec 2013 10:10:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vvq5z-0000Eh-Kg for bug-gnu-emacs@gnu.org; Wed, 25 Dec 2013 10:10:10 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:55680) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vvq5z-0000Cs-Br for bug-gnu-emacs@gnu.org; Wed, 25 Dec 2013 10:10:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Vvq5y-00017k-SA for bug-gnu-emacs@gnu.org; Wed, 25 Dec 2013 10:10:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Kenjiro NAKAYAMA Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 25 Dec 2013 15:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 16198 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: pending patch Original-Received: via spool by 16198-submit@debbugs.gnu.org id=B16198.13879841814277 (code B ref 16198); Wed, 25 Dec 2013 15:10:02 +0000 Original-Received: (at 16198) by debbugs.gnu.org; 25 Dec 2013 15:09:41 +0000 Original-Received: from localhost ([127.0.0.1]:41466 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vvq5Z-00016p-5O for submit@debbugs.gnu.org; Wed, 25 Dec 2013 10:09:41 -0500 Original-Received: from mail-pa0-f44.google.com ([209.85.220.44]:49944) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vvq5S-00016T-6G for 16198@debbugs.gnu.org; Wed, 25 Dec 2013 10:09:34 -0500 Original-Received: by mail-pa0-f44.google.com with SMTP id fa1so7517135pad.3 for <16198@debbugs.gnu.org>; Wed, 25 Dec 2013 07:09:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version:content-type; bh=/G5s0rUJhtPOIzfd4ypbP14OchHCGPhCMsmFsT2UZ6o=; b=V2Ki06ynkOcXRLa3a1ZqpDxn9YyhMVOdLahqD0eGALhAtvjTqw0lukjKcGA5Lgcq8s uQrtw91DUb26S/elPCihMNQUWwUokqq+HIGo5xgiAvrVALW0hlxjchho6BA4A3xWnMPN AJ8C2pOi/8UmAH8YuS9RQddajL/30nk+0x0f/NAuGlgYPzLJYj8973JmCuXMLmZkhcbx NNoYJuPIBA627o+E7rMb7rrzv6FQilEjMZRUBRgaMyDjKJ/i0DzXR7H7wbzMSvwTqSvp gOd9NKl8WOm7RI+iegciEBL8LoZkJ6YzvD1f8qN0gc2ewc8XNUBGQ3di13ZmEugViIik 7s8w== X-Received: by 10.66.160.2 with SMTP id xg2mr38571069pab.23.1387984169020; Wed, 25 Dec 2013 07:09:29 -0800 (PST) Original-Received: from dhcp-193-97.nrt.redhat.com (nat-pool-nrt-u1.redhat.com. [66.187.238.11]) by mx.google.com with ESMTPSA id ik1sm48981368pbc.9.2013.12.25.07.09.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Dec 2013 07:09:27 -0800 (PST) User-agent: mu4e 0.9.9.6pre2; emacs 24.3.50.2 In-reply-to: <87r491l4ki.fsf@building.gnus.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:82580 Archived-At: Thank you Lars, > Lines shouldn't be longer than 80 characters, and these file names may But If I include linefeed and indent in following line, the data has some "\t"s due to the indent. So I think one line is better. (format "Content-Disposition: form-data; name=%S; filename=%S\r\nContent-Type: text/plain; ....) -> With New Line and indent.(Many \t\t\t... are included in the data.) Content-Disposition: form-data; name="test"; filename="~/example.txt"\r\n\t\t\t\t\t\t\tContent-Type: text/plain; charset=utf-8\r\n\t\t\t\t\t\t\tContent-Transfer-Encoding: binary\r\n\r\n -> Non-breaking (The linefeed looks good) Content-Disposition: form-data; name="test"; filename="~/example.txt"\r\n Content-Type: text/plain; charset=utf-8\r\n Content-Transfer-Encoding: binary\r\n\r\n If I misunderstood your explanation, I am sorry. Since I made the patch again, I resend. The patch for the eww.el ([PATCH 2/2]) has no change. Signed-off-by: Kenjiro NAKAYAMA * 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 | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/lisp/gnus/mm-url.el b/lisp/gnus/mm-url.el index 6e83b18..4b5fedb 100644 --- a/lisp/gnus/mm-url.el +++ b/lisp/gnus/mm-url.el @@ -416,13 +416,51 @@ 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 + (format + ;; Encode the name + "Content-Disposition: form-data; name=%S; filename=%S\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Transfer-Encoding: binary\r\n\r\n%s" + (cdr (assoc "name" (cdr data))) (cdr (assoc "filename" (cdr data))) + (cond ((stringp (cdr (assoc "filedata" (cdr data)))) + (cdr (assoc "filedata" (cdr data)))) + ((integerp (cdr (assoc "filedata" (cdr data)))) + (number-to-string (cdr (assoc "filedata" (cdr data)))))))) + ((equal (car data) "submit") + "Content-Disposition: form-data; name=\"submit\"\r\n\r\nSubmit\r\n") + (t + (format + "Content-Disposition: form-data;name=%S\r\n\r\n%s\r\n" + (car data) (concat (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) - (point-max)))) + (or (search-forward "-->" nil t) + (point-max)))) (goto-char (point-min)) (while (re-search-forward "<[^>]+>" nil t) (replace-match "" t t))) -- 1.8.3.1 Regards, Kenjiro larsi@gnus.org writes: > Kenjiro NAKAYAMA writes: > > Looks good. One bit that could perhaps be changed is this: > >> + "Content-Disposition: form-data; name=\"" (cdr (assoc "name" (cdr data))) "\"; filename=\"" (cdr (assoc "filename" (cdr data))) "\"\r\n" > > Lines shouldn't be longer than 80 characters, and these file names may > perhaps contain the " character, which would make these specs invalid? > > It's usually best to use `format' with %S in these cases: > > (setq file "foo\"bar") > > (insert (concat "name=\"" file "\"")) > name="foo"bar" > > (insert (format "name=%S" file)) > name="foo\"bar"