Fri Sep 14 21:08:45 EST 2007 Matt Palmer * Handle action='' in a form tag as if action wasn't specified diff -rN -u old-bugfixes/lib/mechanize/form.rb new-bugfixes/lib/mechanize/form.rb --- old-bugfixes/lib/mechanize/form.rb 2008-10-20 23:30:58.172857136 +1100 +++ new-bugfixes/lib/mechanize/form.rb 2008-10-20 23:30:58.176880125 +1100 @@ -34,6 +34,9 @@ @method = (@form_node['method'] || 'GET').upcase @action = Util::html_unescape(@form_node['action']) + if @action == '' + @action = nil + end @name = @form_node['name'] @enctype = @form_node['enctype'] || 'application/x-www-form-urlencoded' @clicked_buttons = [] diff -rN -u old-bugfixes/test/htdocs/tc_form_action.html new-bugfixes/test/htdocs/tc_form_action.html --- old-bugfixes/test/htdocs/tc_form_action.html 2008-10-20 23:30:58.172857136 +1100 +++ new-bugfixes/test/htdocs/tc_form_action.html 2008-10-20 23:30:58.184882032 +1100 @@ -44,5 +44,27 @@
+ +

Post Form 5

+
+ + + + + +
First Name

+ +
+ +

Post Form 6

+
+ + + + + +
First Name

+ +
diff -rN -u old-bugfixes/test/tc_form_action.rb new-bugfixes/test/tc_form_action.rb --- old-bugfixes/test/tc_form_action.rb 2008-10-20 23:30:58.172857136 +1100 +++ new-bugfixes/test/tc_form_action.rb 2008-10-20 23:30:58.180857716 +1100 @@ -49,4 +49,22 @@ page = form.submit assert_equal("http://localhost:#{PORT}/form_post#1", page.uri.to_s) end + + def test_missing_action + form = @page.form('post_form5') { |f| + f.first_name = "Cletus" + } + assert_equal("http://localhost:#{PORT}/tc_form_action.html", form.action.to_s) + page = form.submit + assert_equal("http://localhost:#{PORT}/tc_form_action.html", page.uri.to_s) + end + + def test_empty_action + form = @page.form('post_form6') { |f| + f.first_name = "Cletus" + } + assert_equal("http://localhost:#{PORT}/tc_form_action.html", form.action.to_s) + page = form.submit + assert_equal("http://localhost:#{PORT}/tc_form_action.html", page.uri.to_s) + end end