diff --git a/dom.d b/dom.d index 8c2ebb7..0bb8f15 100644 --- a/dom.d +++ b/dom.d @@ -843,9 +843,11 @@ class Document : FileResource { selfClosed = true; } - if(strict) - enforce(data[pos] == '>', format("got %s when expecting > (possible missing attribute name)\nContext:\n%s", data[pos], data[pos - 100 .. pos + 100])); - else { + import std.algorithm.comparison; + + if(strict) { + enforce(data[pos] == '>', format("got %s when expecting > (possible missing attribute name)\nContext:\n%s", data[pos], data[max(0, pos - 100) .. min(data.length, pos + 100)])); + } else { // if we got here, it's probably because a slash was in an // unquoted attribute - don't trust the selfClosed value if(!selfClosed) @@ -8893,6 +8895,14 @@ immutable string html = q{ assert(rd.href == "/reviews/8832"); } +unittest { + try { + auto doc = new XmlDocument(""); + } catch(Exception e) { + // good; it should throw an exception, not an error. + } +} + /* Copyright: Adam D. Ruppe, 2010 - 2020 License: Boost License 1.0.