Passing TextField values as plaintext to Mechanize.
Mechanize takes input as plaintext and escapes field values on its own. If the values are escaped before they are passed to Mechanize, the values will be escaped twice. These doubly-escaped values will result in incorrect behavior on the server side.
This commit is contained in:
parent
c3f067b551
commit
846a90e561
|
@ -87,6 +87,8 @@ module Webrat
|
|||
parse_rails_request_params("#{name}=#{escaped_value}")
|
||||
when :merb
|
||||
::Merb::Parse.query("#{name}=#{escaped_value}")
|
||||
when :mechanize
|
||||
{ name => value }
|
||||
else
|
||||
{ name => escaped_value }
|
||||
end
|
||||
|
|
|
@ -66,4 +66,20 @@ module Webrat
|
|||
radio_button.should_not be_checked
|
||||
end
|
||||
end
|
||||
|
||||
describe TextField do
|
||||
it 'should not escape values in mechanize mode' do
|
||||
Webrat.configuration.mode = :mechanize
|
||||
|
||||
html = <<-HTML
|
||||
<html>
|
||||
<input type="text" name="email" value="user@example.com" />
|
||||
</html>
|
||||
HTML
|
||||
|
||||
element = Webrat::XML.css_search(Webrat::XML.document(html), 'input').first
|
||||
text_field = TextField.new(nil, element)
|
||||
text_field.to_param.should == { 'email' => 'user@example.com' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue