Skip to content

Commit

Permalink
escape closed parens in dryml text [#898 state:resolved]
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Mar 27, 2011
1 parent 798e2ca commit 578a8ab
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dryml/lib/dryml/template.rb
Expand Up @@ -133,6 +133,7 @@ def text_with_scriplets_to_erb(s)
when scriplet_rex
t
when /\S+/
t.gsub!(/\)/, '\)')
"<% safe_concat %(#{t}) %>"
else
t
Expand Down Expand Up @@ -549,7 +550,7 @@ def polymorphic_call_type(el)
'this_type'
elsif t =~ /^[A-Z]/
t
elsif t =~ /^[a-z]/ && defined? HoboFields.to_class
elsif t =~ /^[a-z]/ && defined?(HoboFields.to_class)
klass = HoboFields.to_class(t)
klass.name
elsif is_code_attribute?(t)
Expand Down

2 comments on commit 578a8ab

@bryanlarsen
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks hobo-jquery, and probably other stuff.

Here's the tag that breaks:

<def tag="hobo-jquery-assets">
  <stylesheet name='hobo-jquery.css' />
  <javascript name="hobo-jquery.js" />
  <script type="text/javascript">
    jQuery.noConflict();
    jQuery(document).ready(function() {
      hjq.initialize.call(document);
    });
  </script>
</def>

what it's trying to eval:

  def hobo_jquery_assets(all_attributes={}, all_parameters={}); parameters = Dryml::TagParameters.new(all_parameters, []); all_parameters = Dryml::TagParameters.new(all_parameters); _tag_context(all_attributes) do attributes, = _tag_locals(all_attributes, []) ; output_buffer.concat "\n  "
;  concat(stylesheet({:name => "hobo-jquery.css"}, {})) ; output_buffer.concat "\n  "
;  concat(javascript({:name => "hobo-jquery.js"}, {})) ; output_buffer.concat "\n  "
;  safe_concat(%(<script type="text/javascript">));  safe_concat %(
    jQuery.noConflict(\);
    jQuery(document\).ready(function(\) {
      hjq.initialize.call(document\);
    }\);
  ) ;  safe_concat(%(</script>)) ; output_buffer.concat "\n"
;  output_buffer; end; end ;  _register_tag_attrs(:hobo_jquery_assets, []) 

@ddnexus
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Bryan,
I didn't thought that REXML::Text catches also the content of a script tag.
I have to escape both parens.

Please sign in to comment.