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: Fri, 20 Dec 2013 18:29:37 +0900 Message-ID: <87fvpnzx8e.fsf@dhcp-193-97.nrt.redhat.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1387531877 7263 80.91.229.3 (20 Dec 2013 09:31:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 20 Dec 2013 09:31:17 +0000 (UTC) To: 16198@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Dec 20 10:31:22 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 1VtwQU-0006Jm-8U for geb-bug-gnu-emacs@m.gmane.org; Fri, 20 Dec 2013 10:31:22 +0100 Original-Received: from localhost ([::1]:48461 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VtwQT-0007GX-Sz for geb-bug-gnu-emacs@m.gmane.org; Fri, 20 Dec 2013 04:31:21 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47510) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VtwQI-0007G4-TU for bug-gnu-emacs@gnu.org; Fri, 20 Dec 2013 04:31:19 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VtwQA-0003Xz-ED for bug-gnu-emacs@gnu.org; Fri, 20 Dec 2013 04:31:10 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:45490) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VtwQA-0003Xt-Bx for bug-gnu-emacs@gnu.org; Fri, 20 Dec 2013 04:31:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VtwQA-00013s-0c for bug-gnu-emacs@gnu.org; Fri, 20 Dec 2013 04:31: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: Fri, 20 Dec 2013 09:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 16198 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.13875318144005 (code B ref -1); Fri, 20 Dec 2013 09:31:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 20 Dec 2013 09:30:14 +0000 Original-Received: from localhost ([127.0.0.1]:59508 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VtwPN-00012V-PU for submit@debbugs.gnu.org; Fri, 20 Dec 2013 04:30:14 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:45538) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VtwPL-00012M-9b for submit@debbugs.gnu.org; Fri, 20 Dec 2013 04:30:11 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VtwPC-0003H7-Ne for submit@debbugs.gnu.org; Fri, 20 Dec 2013 04:30:11 -0500 Original-Received: from lists.gnu.org ([208.118.235.17]:37140) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VtwPC-0003Gr-Jy for submit@debbugs.gnu.org; Fri, 20 Dec 2013 04:30:02 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47205) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VtwP3-0005ch-T9 for bug-gnu-emacs@gnu.org; Fri, 20 Dec 2013 04:30:02 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VtwOv-000371-G6 for bug-gnu-emacs@gnu.org; Fri, 20 Dec 2013 04:29:53 -0500 Original-Received: from mail-pa0-x22c.google.com ([2607:f8b0:400e:c03::22c]:52352) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VtwOv-00036r-8V for bug-gnu-emacs@gnu.org; Fri, 20 Dec 2013 04:29:45 -0500 Original-Received: by mail-pa0-f44.google.com with SMTP id fa1so2407529pad.3 for ; Fri, 20 Dec 2013 01:29:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=user-agent:from:to:subject:date:message-id:mime-version :content-type; bh=drrzlWRsoVxArEnkbhYVQ6Qx5VQvno05/+uBuzooKXM=; b=erA/ObMFFC2eRQApb7V9ftAvz8oRJVWfvavFXjNZId1iaQDBglBoCIHsBzrOja2LEm 3Au730fMHnPyq1UoUSpZnJheN9V54kbUMVVkKrx1IB2hsbGng+pBLNr0Evsexdgg0viG TohfrzGcI3F9t1FO6OAtLcK9x2VUTbPto77h3BX3Z8Mk6EteUTX3BQqvX1MQVFIwlheW 2dkiAHenV5hqu5FswZTgZTudYwVfAHNRgc1D+QddxuGWL7ySaX20H89OmTUsnjjRJRj2 CLAAro6Qn4ZtJBy8r8ggjum69Fw9xPaqb9VpES+gLeE48zRIzIgczppFqM5s9sD02if+ t8Yg== X-Received: by 10.66.159.234 with SMTP id xf10mr7326395pab.139.1387531784036; Fri, 20 Dec 2013 01:29:44 -0800 (PST) Original-Received: from dhcp-193-97.nrt.redhat.com (nat-pool-nrt-t1.redhat.com. [66.187.238.10]) by mx.google.com with ESMTPSA id xs1sm16909407pac.7.2013.12.20.01.29.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Dec 2013 01:29:43 -0800 (PST) User-agent: mu4e 0.9.9.6pre2; emacs 24.3.50.1 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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:82270 Archived-At: This report includes a patch to eww file upload. Please, review and install it to the official tree if appreciated. * Issue Since Eww does not support file upload(input with type="file"), following HTML can not display and handle properly. example:
Kenjiro NAKAYAMA 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 | 44 +++++++++++++++++++++ lisp/net/eww.el | 108 +++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 138 insertions(+), 14 deletions(-) diff --git a/lisp/gnus/mm-url.el b/lisp/gnus/mm-url.el index 6e83b18..b8a4d46 100644 --- a/lisp/gnus/mm-url.el +++ b/lisp/gnus/mm-url.el @@ -416,6 +416,50 @@ 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" + (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))