Skip to content

Commit

Permalink
Merge pull request #30 from k0kubun/dont-escape-slash
Browse files Browse the repository at this point in the history
Don't escape slash with dynamic attributes
  • Loading branch information
eagletmt committed Nov 6, 2015
2 parents a90dae3 + 5d05833 commit 937c213
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ext/attribute_builder/attribute_builder.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ put_attribute(VALUE buf, VALUE attr_quote, VALUE key, VALUE value)
gh_buf ob = GH_BUF_INIT;

Check_Type(value, T_STRING);
if (houdini_escape_html(&ob, (const uint8_t *)RSTRING_PTR(value), RSTRING_LEN(value))) {
if (houdini_escape_html0(&ob, (const uint8_t *)RSTRING_PTR(value), RSTRING_LEN(value), 0)) {
value = rb_enc_str_new(ob.ptr, ob.size, rb_utf8_encoding());
gh_buf_free(&ob);
}
Expand Down
5 changes: 5 additions & 0 deletions spec/render/attribute_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@
expect(render_string(%q|%span{class: "x\"y'z"} hello|)).to eq(%Q{<span class='x&quot;y&#39;z'>hello</span>\n})
end

it 'does not escape slash' do
expect(render_string(%q|%a{ href: 'http://example.com/' }|)).to eq(%Q{<a href='http://example.com/'></a>\n})
expect(render_string(%q|%a{ {}, href: 'http://example.com/' }|)).to eq(%Q{<a href='http://example.com/'></a>\n})
end

it 'renders only name if value is true' do
expect(render_string(%q|%span{foo: true, bar: 1} hello|)).to eq(%Q{<span bar='1' foo>hello</span>\n})
end
Expand Down

0 comments on commit 937c213

Please sign in to comment.