<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>test/htdocs/test_bad_encoding.html</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -4,6 +4,12 @@
 
 * Bug Fixes:
 
+  * Rescue errors from bogus encodings
+
+=== 0.9.3
+
+* Bug Fixes:
+
   * Do not apply encoding if encoding equals 'none' Thanks Akinori MUSHA!
   * Fixed Page#encoding= when changing the value from or to nil.  Made
     it return the assigned value while at it. (Akinori MUSHA)</diff>
      <filename>CHANGELOG.rdoc</filename>
    </modified>
    <modified>
      <diff>@@ -24,15 +24,15 @@ module WWW
     #  puts form['name']
     class Form
       attr_accessor :method, :action, :name
-    
+
       attr_reader :fields, :buttons, :file_uploads, :radiobuttons, :checkboxes
       attr_accessor :enctype
 
       alias :elements :fields
-    
+
       attr_reader :form_node
       attr_reader :page
-    
+
       def initialize(node, mech=nil, page=nil)
         @enctype = node['enctype'] || 'application/x-www-form-urlencoded'
         @form_node        = node
@@ -137,10 +137,10 @@ module WWW
       end
 
       # This method is sub-method of build_query.
-      # It converts charset of query value of fields into excepted one.
+      # It converts charset of query value of fields into expected one.
       def proc_query(field)
         return unless field.query_value
-        field.query_value.map{|(name, val)| 
+        field.query_value.map{|(name, val)|
           [from_native_charset(name), from_native_charset(val.to_s)]
         }
       end
@@ -149,7 +149,7 @@ module WWW
       def from_native_charset(str, enc=nil)
         if page
           enc ||= page.encoding
-          Util.from_native_charset(str,enc)
+          Util.from_native_charset(str,enc) rescue str
         else
           str
         end
@@ -161,36 +161,36 @@ module WWW
       # be used to create a query string for this form.
       def build_query(buttons = [])
         query = []
-    
+
         fields().each do |f|
           qval = proc_query(f)
           query.push(*qval)
         end
-    
+
         checkboxes().each do |f|
           if f.checked
             qval = proc_query(f)
             query.push(*qval)
           end
         end
-    
+
         radio_groups = {}
         radiobuttons().each do |f|
           fname = from_native_charset(f.name)
           radio_groups[fname] ||= []
-          radio_groups[fname] &lt;&lt; f 
+          radio_groups[fname] &lt;&lt; f
         end
-    
+
         # take one radio button from each group
         radio_groups.each_value do |g|
           checked = g.select {|f| f.checked}
-    
+
           if checked.size == 1
             f = checked.first
             qval = proc_query(f)
             query.push(*qval)
-          elsif checked.size &gt; 1 
-            raise &quot;multiple radiobuttons are checked in the same group!&quot; 
+          elsif checked.size &gt; 1
+            raise &quot;multiple radiobuttons are checked in the same group!&quot;
           end
         end
 
@@ -206,7 +206,7 @@ module WWW
       def add_button_to_query(button)
         @clicked_buttons &lt;&lt; button
       end
-    
+
       # This method calculates the request data to be sent back to the server
       # for this form, depending on if this is a regular post, get, or a
       # multi-part post,
@@ -225,8 +225,8 @@ module WWW
           WWW::Mechanize::Util.build_query_string(query_params)
         end
       end
-    
-      # Removes all fields with name +field_name+. 
+
+      # Removes all fields with name +field_name+.
       def delete_field!(field_name)
         @fields.delete_if{ |f| f.name == field_name}
       end
@@ -255,7 +255,7 @@ module WWW
           alias :#{singular} :#{singular}_with
         eomethod
       end
- 
+
       private
       def parse
         @fields       = []
@@ -263,7 +263,7 @@ module WWW
         @file_uploads = []
         @radiobuttons = []
         @checkboxes   = []
-    
+
         # Find all input tags
         form_node.search('input').each do |node|
           type = (node['type'] || 'text').downcase
@@ -275,7 +275,7 @@ module WWW
           when 'checkbox'
             @checkboxes &lt;&lt; CheckBox.new(node['name'], node['value'], !!node['checked'], self)
           when 'file'
-            @file_uploads &lt;&lt; FileUpload.new(node['name'], nil) 
+            @file_uploads &lt;&lt; FileUpload.new(node['name'], nil)
           when 'submit'
             @buttons &lt;&lt; Button.new(node['name'], node['value'])
           when 'button'
@@ -283,7 +283,7 @@ module WWW
           when 'image'
             @buttons &lt;&lt; ImageButton.new(node['name'], node['value'])
           else
-            @fields &lt;&lt; Field.new(node['name'], node['value'] || '') 
+            @fields &lt;&lt; Field.new(node['name'], node['value'] || '')
           end
         end
 
@@ -318,7 +318,7 @@ module WWW
         1.upto(len) { |i| string &lt;&lt; chars[rand(chars.size-1)] }
         string
       end
-    
+
       def mime_value_quote(str)
         str.gsub(/([&quot;\r\\])/){|s| '\\' + s}
       end
@@ -328,7 +328,7 @@ module WWW
                 &quot;#{mime_value_quote(name)}\&quot;\r\n&quot; +
                 &quot;\r\n#{value}\r\n&quot;
       end
-    
+
       def file_to_multipart(file)
         file_name = file.file_name ? ::File.basename(file.file_name) : ''
         body =  &quot;Content-Disposition: form-data; name=\&quot;&quot; +
@@ -345,7 +345,7 @@ module WWW
         if file.mime_type != nil
           body &lt;&lt; &quot;Content-Type: #{file.mime_type}\r\n&quot;
         end
-    
+
         body &lt;&lt;
           if file.file_data.respond_to? :read
             &quot;\r\n#{file.file_data.read}\r\n&quot;</diff>
      <filename>lib/www/mechanize/form.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,6 +6,14 @@ class TestFormAction &lt; Test::Unit::TestCase
     @page  = @agent.get(&quot;http://localhost/tc_form_action.html&quot;)
   end
 
+  def test_post_with_bad_encoding_does_not_raise_exception
+    @page  = @agent.get(&quot;http://localhost/test_bad_encoding.html&quot;)
+    form = @page.form(:name =&gt; 'post_form1') { |f|
+      f.first_name = &quot;Aaron&quot;
+    }
+    form.submit
+  end
+
   def test_post_encoded_action
     form = @page.form(:name =&gt; 'post_form1') { |f|
       f.first_name = &quot;Aaron&quot;</diff>
      <filename>test/test_form_action.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>aa81122ae40b03297cba811deb2944297d80035a</id>
    </parent>
  </parents>
  <author>
    <name>Aaron Patterson</name>
    <email>aaron.patterson@gmail.com</email>
  </author>
  <url>http://github.com/tenderlove/mechanize/commit/aba71da95c08edb2a018d9a693f14969764e6756</url>
  <id>aba71da95c08edb2a018d9a693f14969764e6756</id>
  <committed-date>2009-06-23T14:27:52-07:00</committed-date>
  <authored-date>2009-06-23T14:27:52-07:00</authored-date>
  <message>dealing with incorrect encoding strings</message>
  <tree>694d341227ca1de1b2eb13a9e89a5740dff5763a</tree>
  <committer>
    <name>Aaron Patterson</name>
    <email>aaron.patterson@gmail.com</email>
  </committer>
</commit>
