GNU bug report logs -
#36520
Form submition in eww doesn't work if file field is left empty
Previous Next
Reported by: Ivaylo Ilionov <ivaylo.ilionov <at> outlook.com>
Date: Sat, 6 Jul 2019 11:29:01 UTC
Severity: normal
Tags: fixed, patch
Fixed in version 27.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 36520 in the body.
You can then email your comments to 36520 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#36520
; Package
emacs
.
(Sat, 06 Jul 2019 11:29:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Ivaylo Ilionov <ivaylo.ilionov <at> outlook.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sat, 06 Jul 2019 11:29:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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
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).
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)))
> (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)))
Details about my emacs:
In GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 2.24.32)
of 2019-07-05 built on debian
Repository revision: f24d47359d9b6621215f20795d585c5024d91783
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12004000
System Description: Debian GNU/Linux 10 (buster)
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#36520
; Package
emacs
.
(Sun, 07 Jul 2019 16:39:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 36520 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
tags 36520 + patch
quit
Ivaylo Ilionov <ivaylo.ilionov <at> 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:
[0001-Fix-fileless-eww-form-submission.patch (text/x-diff, inline)]
From 6c4fdcf2434391236d9ac1a891ba751e82831e37 Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Date: Sun, 7 Jul 2019 15:36:36 +0100
Subject: [PATCH] Fix fileless eww form submission
* lisp/net/eww.el (eww-submit): Ignore file inputs with no
associated file name (bug#36520).
---
lisp/net/eww.el | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 1125929c03..5acc645574 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -1426,15 +1426,15 @@ eww-submit
(push (cons name (plist-get input :value))
values)))
((equal (plist-get input :type) "file")
- (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))
+ (when-let ((file (plist-get input :filename)))
+ (push (list "file"
+ (cons "filedata"
+ (with-temp-buffer
+ (insert-file-contents file)
+ (buffer-string)))
+ (cons "name" name)
+ (cons "filename" file))
+ values)))
((equal (plist-get input :type) "submit")
;; We want the values from buttons if we hit a button if
;; we hit enter on it, or if it's the first button after
--
2.20.1
[Message part 3 (text/plain, inline)]
This is probably fine to push as-is, as it's just a defensive guard, but
I'd rather get confirmation from someone else or play around with an
example of the bug first.
Thanks,
--
Basil
Added tag(s) patch.
Request was from
"Basil L. Contovounesios" <contovob <at> tcd.ie>
to
control <at> debbugs.gnu.org
.
(Sun, 07 Jul 2019 16:39:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#36520
; Package
emacs
.
(Sun, 07 Jul 2019 21:17:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 36520 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Basil L. Contovounesios <contovob <at> 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 <at> tcd.ie>
Sent: Sunday, July 7, 2019 19:38
To: Ivaylo Ilionov
Cc: 36520 <at> 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 <at> 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:
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#36520
; Package
emacs
.
(Sat, 14 Sep 2019 14:57:01 GMT)
Full text and
rfc822 format available.
Message #16 received at 36520 <at> debbugs.gnu.org (full text, mbox):
"Basil L. Contovounesios" <contovob <at> tcd.ie> writes:
> This is probably fine to push as-is, as it's just a defensive guard, but
> I'd rather get confirmation from someone else or play around with an
> example of the bug first.
I did some testing, and it seemed to work fine for me, so I've applied
it to the trunk and pushed it.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Added tag(s) fixed.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Sat, 14 Sep 2019 14:57:02 GMT)
Full text and
rfc822 format available.
bug marked as fixed in version 27.1, send any further explanations to
36520 <at> debbugs.gnu.org and Ivaylo Ilionov <ivaylo.ilionov <at> outlook.com>
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Sat, 14 Sep 2019 14:57:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 13 Oct 2019 11:24:05 GMT)
Full text and
rfc822 format available.
This bug report was last modified 4 years and 190 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.