yet more range violation checks to handle pure garbage

This commit is contained in:
Adam D. Ruppe 2013-05-23 09:16:16 -04:00
parent e263a128ab
commit e44b740688
1 changed files with 11 additions and 1 deletions

12
dom.d
View File

@ -3467,6 +3467,12 @@ class Document : FileResource {
} }
string readAttributeValue() { string readAttributeValue() {
if(pos >= data.length) {
if(strict)
throw new Exception("no attribute value before end of file");
else
return null;
}
switch(data[pos]) { switch(data[pos]) {
case '\'': case '\'':
case '"': case '"':
@ -3810,6 +3816,10 @@ class Document : FileResource {
moreAttributes: moreAttributes:
eatWhitespace(); eatWhitespace();
// same deal as above the switch....
if(!strict && pos >= data.length)
return addTag(false);
switch(data[pos]) { switch(data[pos]) {
case '/': // self closing tag case '/': // self closing tag
return addTag(true); return addTag(true);
@ -3839,7 +3849,7 @@ class Document : FileResource {
attributes[attrName] = attrValue; attributes[attrName] = attrValue;
else if(strict) throw new MarkupException("wtf, zero length attribute name"); else if(strict) throw new MarkupException("wtf, zero length attribute name");
if(!strict && data[pos] == '<') { if(!strict && pos < data.length && data[pos] == '<') {
// this is the broken tag that doesn't have a > at the end // this is the broken tag that doesn't have a > at the end
// let's insert one as a hack // let's insert one as a hack
goto case '>'; goto case '>';