From 8159da80c50ced2e996074edf1f1b14fc8a4e860 Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Thu, 23 May 2013 08:45:02 -0400 Subject: [PATCH] more garbage handling --- dom.d | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dom.d b/dom.d index 366152b..b425092 100644 --- a/dom.d +++ b/dom.d @@ -3446,6 +3446,11 @@ class Document : FileResource { else break; // e.g. . The > should have been after the href, but some shitty files don't do that right and the browser handles it, so we will too, by pretending the > was indeed there pos++; + if(pos == data.length) + if(strict) + throw new Exception("unterminated attribute name"); + else + break; } if(!caseSensitive) @@ -3801,11 +3806,20 @@ class Document : FileResource { default: // it is an attribute string attrName = readAttributeName(); string attrValue = attrName; + if(pos >= data.length) + if(strict) + assert(0, "this should have thrown in readAttributeName"); + else { + data ~= ">"; + goto blankValue; + } if(data[pos] == '=') { pos++; attrValue = readAttributeValue(); } + blankValue: + if(strict && attrName in attributes) throw new MarkupException("Repeated attribute: " ~ attrName);