Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore fields without names in Form#build_query #542

Merged
merged 1 commit into from Feb 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/mechanize/form.rb
Expand Up @@ -305,7 +305,7 @@ def build_query(buttons = [])
successful_controls = []

(fields + checkboxes).reject do |f|
f.node["disabled"]
f.node["disabled"] || f.node["name"] == ""
end.sort.each do |f|
case f
when Mechanize::Form::CheckBox
Expand Down
12 changes: 12 additions & 0 deletions test/test_mechanize_form.rb
Expand Up @@ -65,6 +65,18 @@ def test_build_query_blank_form
assert query.all? { |x| x[1] == '' }
end

def test_build_query_blank_input_name
html = Nokogiri::HTML <<-HTML
<form>
<input type="text" name="" value="foo" />
</form>
HTML

form = Mechanize::Form.new html.at('form'), @mech, @page

assert_equal [], form.build_query
end

def test_build_query_radio_button_duplicate
html = Nokogiri::HTML <<-HTML
<form>
Expand Down