From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Ivaylo Ilionov Newsgroups: gmane.emacs.bugs Subject: bug#36520: Form submition in eww doesn't work if file field is left empty Date: Sun, 7 Jul 2019 20:57:11 +0000 Message-ID: References: , <87d0iler5r.fsf@tcd.ie> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_000_VE1PR08MB5136AAF0D6D0F395E997E85F82F70VE1PR08MB5136eurp_" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="15972"; mail-complaints-to="usenet@blaine.gmane.org" Cc: "36520@debbugs.gnu.org" <36520@debbugs.gnu.org> To: "Basil L. Contovounesios" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jul 07 23:17:31 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hkEXG-0003z9-VY for geb-bug-gnu-emacs@m.gmane.org; Sun, 07 Jul 2019 23:17:27 +0200 Original-Received: from localhost ([::1]:37076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkEXF-0000qg-RA for geb-bug-gnu-emacs@m.gmane.org; Sun, 07 Jul 2019 17:17:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40957) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkEWx-0000qW-DZ for bug-gnu-emacs@gnu.org; Sun, 07 Jul 2019 17:17:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hkEWv-0000Vk-1i for bug-gnu-emacs@gnu.org; Sun, 07 Jul 2019 17:17:07 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48667) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hkEWs-0000SM-AH for bug-gnu-emacs@gnu.org; Sun, 07 Jul 2019 17:17:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hkEWs-0008FU-1e for bug-gnu-emacs@gnu.org; Sun, 07 Jul 2019 17:17:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ivaylo Ilionov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Jul 2019 21:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36520 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 36520-submit@debbugs.gnu.org id=B36520.156253418731652 (code B ref 36520); Sun, 07 Jul 2019 21:17:01 +0000 Original-Received: (at 36520) by debbugs.gnu.org; 7 Jul 2019 21:16:27 +0000 Original-Received: from localhost ([127.0.0.1]:57488 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hkEWH-0008EQ-Mw for submit@debbugs.gnu.org; Sun, 07 Jul 2019 17:16:27 -0400 Original-Received: from mail-oln040092070019.outbound.protection.outlook.com ([40.92.70.19]:5063 helo=EUR03-AM5-obe.outbound.protection.outlook.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hkEDm-0007i3-H4 for 36520@debbugs.gnu.org; Sun, 07 Jul 2019 16:57:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9tx6utHy/wcMWCguMhPWk7oMFpkQ0EJ1Dv2ETnnK+QY=; b=tvVZAgvtuvmKzl4EWzkZ9zpfq7jjnA+AOqo2kFArhRjO5CTyZsbgQOCm+QMb6lvyAzxx9666Fiepvqo7D/mb4siw8Xklv5EqT3V9ykhEsHkt446KM9Po0WPFuh+ZkLSIoKWGDKuRZWaqC5Tc8AO9mjLxmbhktRgGos4toIqd6I45cDCAE1K1wyvxPTiD3poK2TykyQFlgjRSBb1oh7sfpsjHXYsl6eUj6P/xJa24ued4WdjHKhN5NuQebovqL+0lRZOapjeOTkCs6CL4ZQkSJ57GH9bN8r/6pS+hF5GJ+Bk3F41wlZ8ucK+fk7XlrhN04tcbgU2maaFfQmSelSsKgA== Original-Received: from VE1EUR03FT036.eop-EUR03.prod.protection.outlook.com (10.152.18.57) by VE1EUR03HT054.eop-EUR03.prod.protection.outlook.com (10.152.19.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2052.18; Sun, 7 Jul 2019 20:57:11 +0000 Original-Received: from VE1PR08MB5136.eurprd08.prod.outlook.com (10.152.18.59) by VE1EUR03FT036.mail.protection.outlook.com (10.152.19.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2052.18 via Frontend Transport; Sun, 7 Jul 2019 20:57:11 +0000 Original-Received: from VE1PR08MB5136.eurprd08.prod.outlook.com ([fe80::e85f:3673:be4f:f4ee]) by VE1PR08MB5136.eurprd08.prod.outlook.com ([fe80::e85f:3673:be4f:f4ee%5]) with mapi id 15.20.2052.020; Sun, 7 Jul 2019 20:57:11 +0000 Thread-Topic: bug#36520: Form submition in eww doesn't work if file field is left empty Thread-Index: AQHVM+aIxyTPJwinFUyAHbLPc99LtKa/XQe2gABE+jw= In-Reply-To: <87d0iler5r.fsf@tcd.ie> Accept-Language: en-US Content-Language: en-US x-incomingtopheadermarker: OriginalChecksum:EB5BA9B8F64DDED3B644E726482DE04712BF8414612FBB53B937B6DAA83CAD6B; UpperCasedChecksum:F7F8EE65443CF3BD6E02E1FD37F2109CD356CA08FA3180D27A3FD6FEAA74FBB4; SizeAsReceived:6827; Count:43 x-tmn: [INiccTHG1wO8HR/xhn+8n3UkW8+Ksuqe] x-ms-publictraffictype: Email x-incomingheadercount: 43 x-eopattributedmessage: 0 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(5050001)(7020095)(20181119110)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031323274)(2017031324274)(2017031322404)(1601125500)(1603101475)(1701031045); SRVR:VE1EUR03HT054; x-ms-traffictypediagnostic: VE1EUR03HT054: x-microsoft-antispam-message-info: yW5xJSt1Bl8yN6jX/pFx1qozsO5Ec5astENQoXNfZmQ9FnufkVYDEN2u9lSSUHVdwbQm8QSh4Hwdk6SMdJHDZfc+xK5tV5UrDBe/hW9l0DFaOMg1rMcqMtT6vboN/EIlfnL24NhDkaNJ1rT3wX59gkOWg3whz6bK78a4tEzgqhO2sJB6i3SA1Zp7KZpDcl4h X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 7eb51138-13b3-43c3-f0d7-08d7031dae74 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Jul 2019 20:57:11.1139 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR03HT054 X-Mailman-Approved-At: Sun, 07 Jul 2019 17:16:24 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.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" Xref: news.gmane.org gmane.emacs.bugs:162301 Archived-At: --_000_VE1PR08MB5136AAF0D6D0F395E997E85F82F70VE1PR08MB5136eurp_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Basil L. Contovounesios writes: > I wonder if the file not being initialised is a symptom of a problem elsewhere? An example might shed more light on this. It's quite possible that my suggestion is a low quality patch or just hides the real problem. I don't have a good undertanding of the code for eww. I've first encountered the problem in Redmine version 4.0.3. The action which triggered the error was that for changing status of an issue from "New" to "In Progress". The form contains many things including the option to upload files for the issue when changing statuses. Here's a sample web form which demonstrates the problem:
Short comment:
Optional file:

If a file hasn't been chosen the submition doesn't seem to work. If a file is chosen i get a proper error from the server ("not found"). ________________________________ From: Basil L. Contovounesios Sent: Sunday, July 7, 2019 19:38 To: Ivaylo Ilionov Cc: 36520@debbugs.gnu.org Subject: Re: bug#36520: Form submition in eww doesn't work if file field is= left empty tags 36520 + patch quit Ivaylo Ilionov writes: > When submitting form with various fields including one optional > field for file upload, if the file filed is left empty - the > submition doesn't work. > > The error is: Wrong type argument: stringp, nil Could you please give an example of such a form, for reproduction/testing purposes? > I've tracked the problem to the function 'eww-submit' which tries > to open a file for upload (the file was never initialized by the > html form). I wonder if the file not being initialised is a symptom of a problem elsewhere? An example might shed more light on this. > My fix is to check if the property is set in the file "eww.el.gz" after > line 1435: > >> ((equal (plist-get input :type) "file") >> ;; FIX check if property :filename is not nil >> (when (not (null (plist-get input :filename))) FWIW, this is equivalent to (when (plist-get input :filename) ...). >> (push (cons "file" >> (list (cons "filedata" >> (with-temp-buffer >> (insert-file-contents >> (plist-get input :filename)) >> (buffer-string))) >> (cons "name" (plist-get input :name)) >> (cons "filename" (plist-get input :filename)))) >> values))) LGTM. Here's a patch which achieves the same effect and additionally cleans up this code a tiny bit: --_000_VE1PR08MB5136AAF0D6D0F395E997E85F82F70VE1PR08MB5136eurp_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Basil L. Contovounesios <contovob@tcd.ie> writes:
> I wonder if the file n= ot being initialised is a symptom of a problem
elsewhere?  An example might shed more light on this.

It's quite possible that my suggestion is a low quality patch or just
hides the real problem. I don't have a good undertanding of the
code for eww.

I've first encountered the problem in Redmine version 4.0.3.
The action which triggered the error was that for changing status
of an issue from "New" to "In Progress". The form conta= ins
many things including the option to upload files for the issue
when changing statuses.

Here's a sample web form which demonstrates the problem:

<html> <body>
    <form action=3D"/non-existent.cgi" method= =3D"post">
      Short comment: <input name=3D'comment' type=3D= 'text' /><br/>
      Optional file: <input name=3D'file' type=3D'fi= le' /><br/>
      <input type=3D'submit'/><br/>
      <input type=3D'reset'/>
    </form>
</body> </html>

If a file hasn't been chosen the submition doesn't seem to work.
If a file is chosen i get a proper error from the server ("not fo= und").


From: Basil L. Contovoune= sios <contovob@tcd.ie>
Sent: Sunday, July 7, 2019 19:38
To: Ivaylo Ilionov
Cc: 36520@debbugs.gnu.org
Subject: Re: bug#36520: Form submition in eww doesn't work if file f= ield is left empty
 
tags 36520 + patch
quit

Ivaylo Ilionov <ivaylo.ilionov@outlook.com> writes:

> When submitting form with various fields including one optional
> field for file upload, if the file filed is left empty - the
> submition doesn't work.
>
> The error is: Wrong type argument: stringp, nil

Could you please give an example of such a form, for
reproduction/testing purposes?

> I've tracked the problem to the function 'eww-submit' which tries
> to open a file for upload (the file was never initialized by the
> html form).

I wonder if the file not being initialised is a symptom of a problem
elsewhere?  An example might shed more light on this.

> My fix is to check if the property is set in the file "eww.el.gz&= quot; after
> line 1435:
>
>> ((equal (plist-get input :type) "file")
>>  ;; FIX check if property :filename is not nil
>>  (when (not (null (plist-get input :filename)))

FWIW, this is equivalent to (when (plist-get input :filename) ...).

>>    (push (cons "file"
>>         (list (cons "= filedata"
>>       (with-temp-buffer
>>         (insert-file-conte= nts
>>          (plist-get i= nput :filename))
>>         (buffer-string)))<= br> >>        (cons "name" (= plist-get input :name))
>>        (cons "filename&quo= t; (plist-get input :filename))))
>>   values)))

LGTM.  Here's a patch which achieves the same effect and additionally<= br> cleans up this code a tiny bit:

--_000_VE1PR08MB5136AAF0D6D0F395E997E85F82F70VE1PR08MB5136eurp_--