#202 open
Peter Aitken

Unnecessary escaping of date selector fields when used with file field

Reported by Peter Aitken | March 19th, 2009 @ 12:25 PM

When using webrat 0.4.2 and Rails 2.3 RC2 I have hit the following problem.

Give I have a form with a date selector and a attachment file field, and I select a date and have nothing in the file field, the folling attributes arrive correctly at the controllers create action.

my_date(1i): 2007 my_date(2i): 5 my_date(3i): 21 my_attachment:

All looks good.

Then if I attach a file and fill in the date again the controller recieves...

my_date%281i%29: 2007 my_date%282i%29: 5 my_date%283i%29: 21 my_attachment: #<File:0x644cce8>

This results in the my_date attribute not being set in the model due to expecting to recieve keys like,

my_date(1i) and not my_date%281i%29

Comments and changes to this ticket

  • Brian Cooke

    Brian Cooke March 21st, 2009 @ 10:04 AM

    I'm also seeing this with the official rails 2.3 (2.3.2)

  • Erin Staniland

    Erin Staniland April 16th, 2009 @ 10:59 AM

    Me too with Webrat 0.4.4 and Rails 2.3-stable

  • gaffo

    gaffo April 22nd, 2009 @ 01:03 PM

    • Tag changed from select_date, webrat to select_date, verify, webrat
    • State changed from “new” to “open”
  • gaffo

    gaffo April 22nd, 2009 @ 01:04 PM

    attaching the full html that isn't being escaped correctly would be mightly helpful.

  • Tim Peat

    Tim Peat April 24th, 2009 @ 01:58 AM

    FWIW - html for form that produces error

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <title>xxxxxx</title>
    <link href="/stylesheets/application.css?1240503100" media="screen" rel="stylesheet" type="text/css" />
    
    
    <div id='container'>
      <div id='head'>
    
        <div class='logo'>
          <h1>XXXXXX</h1>
        </div>
        <div class='right'>
          <h2>XXXXXXXXXXXXXXXX</h2>
        </div>
        <div class='message'>
          logged in as: XXXXXXXXXXXX
        </div>
    
      </div>
      <div id='navigation'>
        <ul>
          <li><a href="/resources/new">Home</a></li>
        </ul>
        <div class='search'>
          <form action="/site_search" id="site_search" method="get">
            <input class="field" id="site_search_keywords" name="site_search_keywords" type="text" value="Search Site" />
    
            <input class="button" name="commit" type="submit" value="Search" />
          </form>
          <div class="flash_notice">Login successful!</div>
        </div>
      </div>
      <h2>New Resource</h2>
      <form action="/resources" class="new_resource" enctype="multipart/form-data" id="new_resource" method="post"><div style="margin:0;padding:0"><input name="authenticity_token" type="hidden" value="jcgis50F/Z1L6fQe3o7bWPTzyopn2lEgtmEqoaid/sw=" /></div>
        <fieldset>
    
    
          <fieldset>
            <legend>
              Upload Resource
            </legend>
            <ol>
              <li>
                <label for="resource_attachment">Attachment</label>
                <input id="resource_attachment" name="resource[attachment]" size="30" type="file" />
              </li>
    
            </ol>
          </fieldset>
          <fieldset>
            <legend>
              Resource Details
              <ol>
                <li>
                  <label for="resource_title">Title</label>
                  <input id="resource_title" name="resource[title]" size="30" type="text" />
    
                </li>
                <li>
                  <label for="resource_authors">Authors</label>
                  <input id="resource_authors" name="resource[authors]" size="30" type="text" />
                </li>
                <li>
                  <label for="resource_abstract">Abstract</label>
                  <textarea cols="40" id="resource_abstract" name="resource[abstract]" rows="20"></textarea>
    
                </li>
                <li>
                  <label for="resource_resource_type_id">Type</label>
                  <select id="resource_resource_type_id" name="resource[resource_type_id]"><option value="6334613">Corporate publications</option>
                  <option value="240430036">Guides &amp; tools</option>
                  <option value="370997112">Case studies</option>
    
                  <option value="768554198">Policy papers</option>
                  <option value="960711681">Articles</option>
                  <option value="994149445">Web page</option>
                  <option value="1022253142">Reports</option></select>
                </li>
                <li>
                  <label for="resource_publication_date">Publication date</label>
    
                  <select id="resource_publication_date_1i" name="resource[publication_date(1i)]">
                  <option value="2004">2004</option>
                  <option value="2005">2005</option>
                  <option value="2006">2006</option>
                  <option value="2007">2007</option>
                  <option value="2008">2008</option>
    
                  <option selected="selected" value="2009">2009</option>
                  <option value="2010">2010</option>
                  <option value="2011">2011</option>
                  <option value="2012">2012</option>
                  <option value="2013">2013</option>
                  <option value="2014">2014</option>
    
                  </select>
                  <select id="resource_publication_date_2i" name="resource[publication_date(2i)]">
                  <option value="1">January</option>
                  <option value="2">February</option>
                  <option value="3">March</option>
                  <option selected="selected" value="4">April</option>
                  <option value="5">May</option>
    
                  <option value="6">June</option>
                  <option value="7">July</option>
                  <option value="8">August</option>
                  <option value="9">September</option>
                  <option value="10">October</option>
                  <option value="11">November</option>
    
                  <option value="12">December</option>
                  </select>
                  <select id="resource_publication_date_3i" name="resource[publication_date(3i)]">
                  <option value="1">1</option>
                  <option value="2">2</option>
                  <option value="3">3</option>
                  <option value="4">4</option>
    
                  <option value="5">5</option>
                  <option value="6">6</option>
                  <option value="7">7</option>
                  <option value="8">8</option>
                  <option value="9">9</option>
                  <option value="10">10</option>
    
                  <option value="11">11</option>
                  <option value="12">12</option>
                  <option value="13">13</option>
                  <option value="14">14</option>
                  <option value="15">15</option>
                  <option value="16">16</option>
    
                  <option value="17">17</option>
                  <option value="18">18</option>
                  <option value="19">19</option>
                  <option value="20">20</option>
                  <option value="21">21</option>
                  <option value="22">22</option>
    
                  <option value="23">23</option>
                  <option selected="selected" value="24">24</option>
                  <option value="25">25</option>
                  <option value="26">26</option>
                  <option value="27">27</option>
                  <option value="28">28</option>
    
                  <option value="29">29</option>
                  <option value="30">30</option>
                  <option value="31">31</option>
                  </select>
                </li>
                <li>
                  <label for="resource_go_live_at">Go live at</label>
    
                  <select id="resource_go_live_at_1i" name="resource[go_live_at(1i)]">
                  <option value="2004">2004</option>
                  <option value="2005">2005</option>
                  <option value="2006">2006</option>
                  <option value="2007">2007</option>
                  <option value="2008">2008</option>
    
                  <option selected="selected" value="2009">2009</option>
                  <option value="2010">2010</option>
                  <option value="2011">2011</option>
                  <option value="2012">2012</option>
                  <option value="2013">2013</option>
                  <option value="2014">2014</option>
    
                  </select>
                  <select id="resource_go_live_at_2i" name="resource[go_live_at(2i)]">
                  <option value="1">January</option>
                  <option value="2">February</option>
                  <option value="3">March</option>
                  <option selected="selected" value="4">April</option>
                  <option value="5">May</option>
    
                  <option value="6">June</option>
                  <option value="7">July</option>
                  <option value="8">August</option>
                  <option value="9">September</option>
                  <option value="10">October</option>
                  <option value="11">November</option>
    
                  <option value="12">December</option>
                  </select>
                  <select id="resource_go_live_at_3i" name="resource[go_live_at(3i)]">
                  <option value="1">1</option>
                  <option value="2">2</option>
                  <option value="3">3</option>
                  <option value="4">4</option>
    
                  <option value="5">5</option>
                  <option value="6">6</option>
                  <option value="7">7</option>
                  <option value="8">8</option>
                  <option value="9">9</option>
                  <option value="10">10</option>
    
                  <option value="11">11</option>
                  <option value="12">12</option>
                  <option value="13">13</option>
                  <option value="14">14</option>
                  <option value="15">15</option>
                  <option value="16">16</option>
    
                  <option value="17">17</option>
                  <option value="18">18</option>
                  <option value="19">19</option>
                  <option value="20">20</option>
                  <option value="21">21</option>
                  <option value="22">22</option>
    
                  <option value="23">23</option>
                  <option selected="selected" value="24">24</option>
                  <option value="25">25</option>
                  <option value="26">26</option>
                  <option value="27">27</option>
                  <option value="28">28</option>
    
                  <option value="29">29</option>
                  <option value="30">30</option>
                  <option value="31">31</option>
                  </select>
                   &mdash; <select id="resource_go_live_at_4i" name="resource[go_live_at(4i)]">
                  <option value="00">00</option>
    
                  <option value="01">01</option>
                  <option value="02">02</option>
                  <option value="03">03</option>
                  <option value="04">04</option>
                  <option value="05">05</option>
                  <option value="06">06</option>
    
                  <option value="07">07</option>
                  <option selected="selected" value="08">08</option>
                  <option value="09">09</option>
                  <option value="10">10</option>
                  <option value="11">11</option>
                  <option value="12">12</option>
    
                  <option value="13">13</option>
                  <option value="14">14</option>
                  <option value="15">15</option>
                  <option value="16">16</option>
                  <option value="17">17</option>
                  <option value="18">18</option>
    
                  <option value="19">19</option>
                  <option value="20">20</option>
                  <option value="21">21</option>
                  <option value="22">22</option>
                  <option value="23">23</option>
                  </select>
    
                   : <select id="resource_go_live_at_5i" name="resource[go_live_at(5i)]">
                  <option value="00">00</option>
                  <option value="10">10</option>
                  <option value="20">20</option>
                  <option value="30">30</option>
                  <option value="40">40</option>
    
                  <option selected="selected" value="50">50</option>
                  </select>
                </li>
                <li>
                  <label for="resource_private">Private?</label>
                  <input name="resource[private]" type="hidden" value="0" /><input id="resource_private" name="resource[private]" type="checkbox" value="1" />
                </li>
              </ol>
    
            </legend>
          </fieldset>
          <fieldset id='categories'>
            <legend>
              Categories
            </legend>
            <span>
              <input id="Deliberation &amp; Dialogue" name="resource[category_ids][]" type="checkbox" value="357751860" />
              <label for="Deliberation &amp; Dialogue">Deliberation & Dialogue</label>
    
            </span>
            <span>
              <input id="Evaluation" name="resource[category_ids][]" type="checkbox" value="430326217" />
              <label for="Evaluation">Evaluation</label>
            </span>
            <span>
              <input id="Delivering Efficiency" name="resource[category_ids][]" type="checkbox" value="442820205" />
              <label for="Delivering Efficiency">Delivering Efficiency</label>
    
            </span>
            <span>
              <input id="Public Service Futures" name="resource[category_ids][]" type="checkbox" value="866167485" />
              <label for="Public Service Futures">Public Service Futures</label>
            </span>
            <span>
              <input id="Strengthening Partnerships" name="resource[category_ids][]" type="checkbox" value="953125641" />
              <label for="Strengthening Partnerships">Strengthening Partnerships</label>
    
            </span>
            <span>
              <input id="Coaching" name="resource[category_ids][]" type="checkbox" value="986866124" />
              <label for="Coaching">Coaching</label>
            </span>
            <span>
              <input id="Managing Change" name="resource[category_ids][]" type="checkbox" value="996332877" />
              <label for="Managing Change">Managing Change</label>
    
            </span>
            <span>
              <input id="Management Development" name="resource[category_ids][]" type="checkbox" value="1003532957" />
              <label for="Management Development">Management Development</label>
            </span>
            <span>
              <input id="Leadership" name="resource[category_ids][]" type="checkbox" value="1054583384" />
              <label for="Leadership">Leadership</label>
    
            </span>
          </fieldset>
          <fieldset>
            <ol>
              <li>
                <input id="resource_submit" name="commit" type="submit" value="Save" />
              </li>
            </ol>
          </fieldset>
    
        </fieldset>
      </form>
    </div>
    
    
  • Tim Peat

    Tim Peat April 24th, 2009 @ 02:00 AM

    Parameters passed for the above form:

    {"commit"=>"Save", "resource"=>{"publication_date%283i%29"=>"23", "title"=>"Test Title", "abstract"=>"Test Title Abstract", "attachment"=>#<File:/var/folders/v8/v8Ug4QpUH0ypnIi3p38Ogk+++TI/-Tmp-/RackMultipart.329.1>, "publication_date%281i%29"=>"2004", "private"=>"1", "go_live_at%283i%29"=>"23", "publication_date%282i%29"=>"11", "go_live_at%284i%29"=>"11", "category_ids"=>"6869", "go_live_at%281i%29"=>"2004", "go_live_at%282i%29"=>"11", "resource_type_id"=>"52", "authors"=>"Tim Peat", "go_live_at%285i%29"=>"20"}}

  • Tim Peat

    Tim Peat April 24th, 2009 @ 02:03 AM

    The above output using, Rails 2.3.2 and Webrat 0.4.3

  • Davis Zanetti Cabral
  • Thomas Sinclair

    Thomas Sinclair October 20th, 2009 @ 11:45 PM

    Bump to this issue, I'm with:

    Webrat 0.5.3
    Rails 2.3.2

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Ruby Acceptance Testing for Web applications.

Shared Ticket Bins

Pages