diff options
author | Tomas Divis <tomas.divis@nic.cz> | 2016-07-20 17:31:09 +0200 |
---|---|---|
committer | Tomas Divis <tomas.divis@nic.cz> | 2016-07-20 17:31:09 +0200 |
commit | efb70762d057b80f832c8a36d089a4ffb498c379 (patch) | |
tree | 5fe7c7065d0d98734564e5275ed1159c21a1b80f /src | |
parent | 85a5d43e6aee3ac29015c0fbd3af7b6cf7f2010b (diff) | |
download | python-lxml-efb70762d057b80f832c8a36d089a4ffb498c379.tar.gz |
Exclude `file` field `value` from `FormElement.form_values`.
Similar to `submit`, `image` and `reset`, browsers don't send `file` field values in the POST when form is submitted. `FormElement.form_values` method already correctly excluded `submit`, `image` and `reset` fields, now it also excludes the `file` fields.
Diffstat (limited to 'src')
-rw-r--r-- | src/lxml/html/__init__.py | 2 | ||||
-rw-r--r-- | src/lxml/html/tests/test_forms.txt | 2 |
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 |