Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Reject malformed lex results for tag attributes.

  • Loading branch information...
commit 0770f61e544e946508d709de09811f6d0b32977f 1 parent 291be8e
@creationix authored
Showing with 11 additions and 4 deletions.
  1. +7 −3 lib/haml.js
  2. +3 −0  test/alt_attribs.haml
  3. +1 −1  test/alt_attribs.html
View
10 lib/haml.js
@@ -68,9 +68,13 @@ var Haml;
seperator = (open === '{') ? ',' : ' ';
function process_pair() {
- var key = line.substr(pair.start, pair.middle - pair.start).trim(),
- value = line.substr(pair.middle + 1, pair.end - pair.middle - 1).trim();
- attributes[key] = value;
+ if (typeof pair.start === 'number' &&
+ typeof pair.middle === 'number' &&
+ typeof pair.end === 'number') {
+ var key = line.substr(pair.start, pair.middle - pair.start).trim(),
+ value = line.substr(pair.middle + 1, pair.end - pair.middle - 1).trim();
+ attributes[key] = value;
+ }
pair = {
start: null,
middle: null,
View
3  test/alt_attribs.haml
@@ -1 +1,4 @@
%tag(name="value" name2=true ns:tag=100)
+%input#space-end(type="hidden" value="3" )
+%input#space-start( type="hidden" value="3" )
+%input#space-middle(type="hidden" value="3")
View
2  test/alt_attribs.html
@@ -1 +1 @@
-<tag name="value" name2="name2" ns:tag="100"></tag>
+<tag name="value" name2="name2" ns:tag="100"></tag><input type="hidden" value="3" id="space-end" /><input type="hidden" value="3" id="space-start" /><input type="hidden" value="3" id="space-middle" />
Please sign in to comment.
Something went wrong with that request. Please try again.