bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#36520: Form submition in eww doesn't work if file field is left empt


From: Ivaylo Ilionov
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

Basil L. Contovounesios <contovob@tcd.ie> 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:

<html> <body>
    <form action="" method="post">
      Short comment: <input name='comment' type='text' /><br/>
      Optional file: <input name='file' type='file' /><br/>
      <input type='submit'/><br/>
      <input type='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 found").


From: Basil L. Contovounesios <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 field 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" 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:


reply via email to

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