Skip to content

Commit

Permalink
< or </ followed by whitespace is never a tag. who knew.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmont committed Jun 6, 2012
1 parent e24d88f commit 7867524
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ function callbackText(context) {
function parseNext(context) {
var current = context.current, buffer = current;
if (current == '<') {
buffer += context.readUntilNonWhitespace();
buffer += context.read();
if (context.current === '/') {
buffer += context.readUntilNonWhitespace();
buffer += context.read();
if (nameRegex.test(context.current)) {
callbackText(context);
parseEndElement(context);
Expand Down
14 changes: 7 additions & 7 deletions tests/malformed-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ describe('Malformed HTML', function() {
textCount.should.equal(1);
});

it('< followed by a letter without a following > is still a tag', function() {
it('< followed by whitespace is not a tag', function() {
var openCount = 0, textCount = 0;
helpers.parseString('< foo', {
helpers.parseString('< foo>', {
openElement: function(name) {
name.should.equal('foo');
openCount++;
},

text: function(value) {
value.should.equal('< foo>');
textCount++;
}
});

openCount.should.equal(1);
textCount.should.equal(0);
openCount.should.equal(0);
textCount.should.equal(1);
});

it('< followed by ! but not cdata or comment should be a text node', function() {
Expand Down Expand Up @@ -63,13 +63,13 @@ describe('Malformed HTML', function() {

it('</ not followed by a letter is text', function() {
var closeCount = 0, textCount = 0;
helpers.parseString('</5', {
helpers.parseString('</ foo>', {
closeElement: function(name) {
closeCount++;
},

text: function(value) {
value.should.equal('</5');
value.should.equal('</ foo>');
textCount++;
}
});
Expand Down
2 changes: 1 addition & 1 deletion tests/open-and-close-tag-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('opening and closing tags', function() {

it('tag names with weird whitespace', function() {
var openCount = 0, closeCount = 0;
helpers.parseString('< \n foo\n></ \n bar >', {
helpers.parseString('<foo\n></bar \n >', {
openElement: function(name) {
name.should.equal('foo');
openCount++;
Expand Down

0 comments on commit 7867524

Please sign in to comment.