From 4964425cc3a0c240f0b6175cbe291c7cdd3a85ac Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Tue, 4 Jun 2013 08:50:38 -0400 Subject: [PATCH] minor bugs in new stuff --- dom.d | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/dom.d b/dom.d index 400cd0f..c893897 100644 --- a/dom.d +++ b/dom.d @@ -3680,7 +3680,9 @@ class Document : FileResource { parseError("Attributes must be quoted"); // read until whitespace or terminator (/ or >) auto start = pos; - while(data[pos] != '>' && + while( + pos < data.length && + data[pos] != '>' && // unquoted attributes might be urls, so gotta be careful with them and self-closed elements !(data[pos] == '/' && pos + 1 < data.length && data[pos+1] == '>') && data[pos] != ' ' && data[pos] != '\n' && data[pos] != '\t') @@ -3830,17 +3832,19 @@ class Document : FileResource { auto start = pos; while(pos < data.length && data[pos] != '>') pos++; + + auto bangEnds = pos; if(pos == data.length) { if(strict) throw new MarkupException("unclosed processing instruction ()"); } else pos++; // skipping the > if(parseSawBangInstruction !is null) - if(parseSawBangInstruction(data[start .. pos])) { + if(parseSawBangInstruction(data[start .. bangEnds])) { // FIXME: these should be able to modify the parser state, // doing things like adding entities, somehow. - return Ele(3, new BangInstruction(this, data[start .. pos]), null); + return Ele(3, new BangInstruction(this, data[start .. bangEnds]), null); } } @@ -4040,7 +4044,9 @@ class Document : FileResource { if(strict) throw new Exception("tag " ~ tagName ~ " never closed"); else { - // let's call it totally empty + // let's call it totally empty and do the rest of the file as text. doing it as html could still result in some weird stuff like if(a<4) being read as <4 being a tag so it comes out if(a<4> and other weirdness) It is either a closed script tag or the rest of the file is forfeit. + e = new TextNode(this, data[pos .. $]); + pos = data.length; } } else { ending += pos; @@ -4168,6 +4174,9 @@ class Document : FileResource { if(!strict && pos >= data.length) return addTag(false); + if(strict && pos >= data.length) + throw new MarkupException("tag open, didn't find > before end of file"); + switch(data[pos]) { case '/': // self closing tag return addTag(true);