[Haml] Fix a parsing bug for HTML-style attributes.

This commit is contained in:
Nathan Weizenbaum 2010-01-30 15:58:50 -08:00
parent fc26667ae3
commit e724b98cd7
3 changed files with 12 additions and 1 deletions

View File

@ -15,6 +15,8 @@
make sure error reporting uses the correct line numbers,
and allow multi-line expressions.
* Fix a parsing bug for HTML-style attributes including `#`.
## [2.2.17](http://github.com/nex3/haml/commit/2.2.16)
* Fix compilation of HTML5 doctypes when using `html2haml`.

View File

@ -673,7 +673,7 @@ END
return name, [:dynamic, var]
end
re = /((?:\\.|\#[^{]|[^#{quote}\\#])*#?)(#{quote}|#\{)/
re = /((?:\\.|\#(?!\{)|[^#{quote}\\#])*)(#{quote}|#\{)/
content = []
loop do
return false unless scanner.scan(re)

View File

@ -607,6 +607,15 @@ HTML
HAML
end
def test_html_attributes_with_hash
assert_equal("<a href='#' rel='top'>Foo</a>\n",
render('%a(href="#" rel="top") Foo'))
assert_equal("<a href='#'>Foo</a>\n",
render('%a(href="#") #{"Foo"}'))
assert_equal("<a href='#\"'></a>\n", render('%a(href="#\\"")'))
end
# HTML escaping tests
def test_ampersand_equals_should_escape