Hi,
I don't know much about ruby, nor rails, nor reporting bugs, nor
anything.
But I think I've found a bug in rails 2.3.8.
I have made a test case with the following files:
test.erb:
<!-- begin test.erb -->
<form>
<%= text_field(:test, :dna, {:value => @test.dna, :size => "8", :maxlength
=> "9"})%>
<%= submit_tag "Test" %>
</form>
<div id="new">
</div>
<%= update_page_tag { |page| page[:new].replace_html(render(:partial =>
'test_partial' ) ) } %>
<%= set_focus_to_id 'test_dna' %>
<!-- end test.erb -->
test_partial.erb
<!-- begin test_partial.erb -->
<h1>There is a problem somewhere around here!!</h1>
<%= set_focus_to_id "it_doesnt_matter" %>
<!-- end _test_partial.erb -->
This is generating erroneous javascript in the output file
(HTML) like:
<!-- begin bad script -->
<script type="text/javascript">
//<![CDATA[
try {
$("new").update("<h1>There is a problem somewhere around here!!</h1>\n
<script type=\"text/javascript\">
\n//<![CDATA[\n$('it_doesnt_matter').focus()\n//]]>\n
</script>
\n");
} catch (e) { alert('RJS error:\n\n' + e.toString());
alert('$(\"new\").update(\"<h1>There is a problem somewhere around
here!!</h1>\\n
<script type=\\\"text/javascript\\\">\\n//
<![CDATA[\\n$(\'it_doesnt_matter\').focus()\\n//]]>\\n
</script>
\\n\");'); throw e }
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
$('test_dna').focus()
//]]>
</script>
<!-- end bad script -->
The same test code in rails 1.2.6 renders as it
should be, escaping some characters:
<!-- begin good script -->
<script type="text/javascript">
//<![CDATA[
try {
$("new").update("\074h1\076There is a problem somewhere around
here!!\074/h1\076\n\074script
type=\"text/javascript\"\076\n//\074![CDATA[\n$('it_doesnt_matter').focus()\n//]]\076\n\074/script\076
\n");
} catch (e) { alert('RJS error:\n\n' + e.toString());
alert('$(\"new\").update(\"\\074h1\\076There is a problem somewhere around
here!!\\074/h1\\076\\n\\074script
type=\\\"text/javascript\\\"\\076\\n//\\074![CDATA[\\n$(\'it_doesnt_matter\').focus()\\n//]]\\076\\n\\074/script\\076
\\n\");'); throw e }
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
$('test_dna').focus()
//]]>
</script>
<!-- end good script -->
I could try to track the problem further, but I have no idea
where to
look.
Any help will be appreciated.
Regards,
Ernesto