Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Wrong results when parsing mixed-case tags #41

Closed
wants to merge 1 commit into from

1 participant

@geca

Prior to this patch, I got different results for these lines:

<html><head></head><body>foo</body></html>
<html><head></HEAD><body>foo</BODY></HTML>

Now you get the same thing for either of them:

[ { raw: 'html',
    data: 'html',
    type: 'tag',
    name: 'html',
    children: 
     [ { raw: 'head', data: 'head', type: 'tag', name: 'head' },
       { raw: 'body',
         data: 'body',
         type: 'tag',
         name: 'body',
         children: [ { raw: 'foo', data: 'foo', type: 'text' } ] } ] } ]

All of the tests still pass.

@geca geca closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 26, 2011
  1. @geca

    Fixed matching mixed case tags.

    geca authored
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/htmlparser.js
View
4 lib/htmlparser.js
@@ -684,8 +684,8 @@ function DefaultHandler (callback, options) {
var baseName = element.name.substring(1);
if (!this.isEmptyTag(element)) {
var pos = this._tagStack.length - 1;
- while (pos > -1 && this._tagStack[pos--].name != baseName) { }
- if (pos > -1 || this._tagStack[0].name == baseName)
+ while (pos > -1 && this._tagStack[pos--].name.toLowerCase() != baseName.toLowerCase()) { }
+ if (pos > -1 || this._tagStack[0].name.toLowerCase() == baseName.toLowerCase())
while (pos < this._tagStack.length - 1)
this._tagStack.pop();
}
Something went wrong with that request. Please try again.