summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorscoder <stefan_ml@behnel.de>2016-07-21 08:06:17 +0200
committerGitHub <noreply@github.com>2016-07-21 08:06:17 +0200
commitb41ee9f222ed2668f5d9e26eb496cbd61d7e867b (patch)
treea3ad1e1144551771ba18e0b3bc94f69ea50951b6
parent5da090bdd9811ee2d8e76bb536fd84dc9d556033 (diff)
parentefb70762d057b80f832c8a36d089a4ffb498c379 (diff)
downloadpython-lxml-b41ee9f222ed2668f5d9e26eb496cbd61d7e867b.tar.gz
Merge pull request #199 from tdivis/exclude-file-from-form-values
Exclude `file` field `value` from `FormElement.form_values`.
-rw-r--r--src/lxml/html/__init__.py2
-rw-r--r--src/lxml/html/tests/test_forms.txt2
2 files changed, 3 insertions, 1 deletions
diff --git a/src/lxml/html/__init__.py b/src/lxml/html/__init__.py
index 1a1d7d28..ba36272d 100644
--- a/src/lxml/html/__init__.py
+++ b/src/lxml/html/__init__.py
@@ -1027,7 +1027,7 @@ class FormElement(HtmlElement):
"Unexpected tag: %r" % el)
if el.checkable and not el.checked:
continue
- if el.type in ('submit', 'image', 'reset'):
+ if el.type in ('submit', 'image', 'reset', 'file'):
continue
value = el.value
if value is not None:
diff --git a/src/lxml/html/tests/test_forms.txt b/src/lxml/html/tests/test_forms.txt
index 25c6529a..a86ff8a3 100644
--- a/src/lxml/html/tests/test_forms.txt
+++ b/src/lxml/html/tests/test_forms.txt
@@ -28,6 +28,7 @@
... <option value="3">number 3</option>
... <option>number 4</option>
... </select>
+... <input type="file" name="file_field" value="nonsense_value">
... <input type="submit" name="submit1" value="submit">
... <input type="submit" name="submit2" value="submit">
... <input type="reset" name="reset1">linksys
@@ -142,6 +143,7 @@ hidden_field=new+value&text_field=text_value&single_checkbox=on&single_checkbox2
>>> for name, value in sorted(fields.items()):
... print('%s: %r' % (name, value))
check_group: <CheckboxValues {'1', '2', '3'} for checkboxes name='check_group'>
+file_field: 'nonsense_value'
hidden_field: 'new value'
radios: None
reset1: None