unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Ivaylo Ilionov <ivaylo.ilionov@outlook.com>
To: "Basil L. Contovounesios" <contovob@tcd.ie>
Cc: "36520@debbugs.gnu.org" <36520@debbugs.gnu.org>
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	[thread overview]
Message-ID: <VE1PR08MB5136AAF0D6D0F395E997E85F82F70@VE1PR08MB5136.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <87d0iler5r.fsf@tcd.ie>

[-- Attachment #1: Type: text/plain, Size: 2762 bytes --]

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="/non-existent.cgi" 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:


[-- Attachment #2: Type: text/html, Size: 6209 bytes --]

  reply	other threads:[~2019-07-07 20:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-06 10:39 bug#36520: Form submition in eww doesn't work if file field is left empty Ivaylo Ilionov
2019-07-07 16:38 ` Basil L. Contovounesios
2019-07-07 20:57   ` Ivaylo Ilionov [this message]
2019-09-14 14:55   ` Lars 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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=VE1PR08MB5136AAF0D6D0F395E997E85F82F70@VE1PR08MB5136.eurprd08.prod.outlook.com \
    --to=ivaylo.ilionov@outlook.com \
    --cc=36520@debbugs.gnu.org \
    --cc=contovob@tcd.ie \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).