Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: haml/haml
...
head fork: doxavore/haml
Checking mergeability… Don't worry, you can still create the pull request.
  • 1 commit
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jul 22, 2011
@doxavore doxavore Use character code entities for attribute value replacements.
When attribute values contain both an apostrophe and a double quote,
we should substitute the character being used to wrap the value with
its key code instead of named/keyword entities (for IE support).

Fixes #418.
04ed74e
View
2  doc-src/HAML_CHANGELOG.md
@@ -14,6 +14,8 @@
* Fix an issue where destructive modification was sometimes performed on Rails SafeBuffers.
+* Use character code entities for attribute value replacements instead of named/keyword entities.
+
## 3.1.1
* Update the vendored Sass to version 3.1.0.
View
4 lib/haml/compiler.rb
@@ -346,7 +346,7 @@ def push_generated_script(text)
# This is a class method so it can be accessed from Buffer.
def self.build_attributes(is_html, attr_wrapper, escape_attrs, attributes = {})
- quote_escape = attr_wrapper == '"' ? """ : "'"
+ quote_escape = attr_wrapper == '"' ? """ : "'"
other_quote_char = attr_wrapper == '"' ? "'" : '"'
if attributes['data'].is_a?(Hash)
@@ -379,7 +379,7 @@ def self.build_attributes(is_html, attr_wrapper, escape_attrs, attributes = {})
value = Haml::Helpers.preserve(escaped)
if escape_attrs
# We want to decide whether or not to escape quotes
- value = value.gsub('"', '"')
+ value = value.gsub('"', '"').gsub('"', '"')
this_attr_wrapper = attr_wrapper
if value.include? attr_wrapper
if value.include? other_quote_char
View
4 test/haml/engine_test.rb
@@ -1094,7 +1094,7 @@ def test_attr_wrapper
assert_equal("<p strange=*attrs*></p>\n", render("%p{ :strange => 'attrs'}", :attr_wrapper => '*'))
assert_equal("<p escaped='quo\"te'></p>\n", render("%p{ :escaped => 'quo\"te'}", :attr_wrapper => '"'))
assert_equal("<p escaped=\"quo'te\"></p>\n", render("%p{ :escaped => 'quo\\'te'}", :attr_wrapper => '"'))
- assert_equal("<p escaped=\"q'uo&quot;te\"></p>\n", render("%p{ :escaped => 'q\\'uo\"te'}", :attr_wrapper => '"'))
+ assert_equal("<p escaped=\"q'uo&#34;te\"></p>\n", render("%p{ :escaped => 'q\\'uo\"te'}", :attr_wrapper => '"'))
assert_equal("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n", render("!!! XML", :attr_wrapper => '"'))
end
@@ -1466,7 +1466,7 @@ def test_html5_data_attributes
assert_equal("<div data-one_plus_one='2'></div>\n",
render("%div{:data => {:one_plus_one => 1+1}}"))
- assert_equal("<div data-foo='Here&apos;s a \"quoteful\" string.'></div>\n",
+ assert_equal("<div data-foo='Here&#39;s a \"quoteful\" string.'></div>\n",
render(%{%div{:data => {:foo => %{Here's a "quoteful" string.}}}})) #'
end

No commit comments for this range

Something went wrong with that request. Please try again.