mirror of https://github.com/scrapy/scrapy.git
forms: do not submit reset inputs
This commit is contained in:
parent
65135db70c
commit
b326b87154
|
|
@ -91,7 +91,7 @@ def _get_inputs(form, formdata, dont_click, clickdata, response):
|
|||
|
||||
inputs = form.xpath('descendant::textarea'
|
||||
'|descendant::select'
|
||||
'|descendant::input[@type!="submit" and @type!="image" '
|
||||
'|descendant::input[@type!="submit" and @type!="image" and @type!="reset"'
|
||||
'and ((@type!="checkbox" and @type!="radio") or @checked)]')
|
||||
values = [(k, u'' if v is None else v) \
|
||||
for k, v in (_value(e) for e in inputs) \
|
||||
|
|
|
|||
|
|
@ -324,6 +324,18 @@ class FormRequestTest(RequestTest):
|
|||
fs = _qs(req)
|
||||
self.assertEqual(fs, {'i1': ['i1v']})
|
||||
|
||||
def test_from_response_dont_submit_reset_as_input(self):
|
||||
response = _buildresponse(
|
||||
"""<form>
|
||||
<input type="hidden" name="i1" value="i1v">
|
||||
<input type="text" name="i2" value="i2v">
|
||||
<input type="reset" name="resetme">
|
||||
<input type="submit" name="i3" value="i3v">
|
||||
</form>""")
|
||||
req = self.request_class.from_response(response, dont_click=True)
|
||||
fs = _qs(req)
|
||||
self.assertEqual(fs, {'i1': ['i1v'], 'i2': ['i2v']})
|
||||
|
||||
def test_from_response_multiple_clickdata(self):
|
||||
response = _buildresponse(
|
||||
"""<form action="get.php" method="GET">
|
||||
|
|
|
|||
Loading…
Reference in New Issue