range violation checks on tag soup

This commit is contained in:
Adam D. Ruppe 2013-05-23 08:53:21 -04:00
parent 8159da80c5
commit e263a128ab
1 changed files with 13 additions and 1 deletions

14
dom.d
View File

@ -3425,7 +3425,14 @@ class Document : FileResource {
auto start = pos;
while( data[pos] != '>' && data[pos] != '/' &&
data[pos] != ' ' && data[pos] != '\n' && data[pos] != '\t')
{
pos++;
if(pos == data.length)
if(strict)
throw new Exception("tag name incomplete when file ended");
else
break;
}
if(!caseSensitive)
return toLower(data[start..pos]);
@ -3661,7 +3668,7 @@ class Document : FileResource {
if(!selfClosed)
selfClosed = tagName.isInArray(selfClosedElements);
while(data[pos] != '>')
while(pos < data.length && data[pos] != '>')
pos++;
}
@ -3785,6 +3792,11 @@ class Document : FileResource {
return Ele(0, e, null);
}
// if a tag was opened but not closed by end of file, we can arrive here
if(!strict && pos >= data.length)
return addTag(false);
//else if(strict) assert(0); // should be caught before
switch(data[pos]) {
default: assert(0);
case '/': // self closing tag