From c9e169ea98c8c3a3bcad22b93bf1420a76d5aa3f Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Mon, 3 Jun 2013 09:15:33 -0400 Subject: [PATCH] script range check --- dom.d | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/dom.d b/dom.d index a04d35b..863d335 100644 --- a/dom.d +++ b/dom.d @@ -3720,14 +3720,25 @@ class Document : FileResource { if(tagName == "script" || tagName == "style") { if(!selfClosed) { string closer = ""; - auto ending = indexOf(data[pos..$], closer); - if(loose && ending == -1) + typeof(indexOf(data, closer)) ending; + if(pos >= data.length) + ending = -1; + else + ending = indexOf(data[pos..$], closer); + + if(loose && ending == -1 && pos < data.length) ending = indexOf(data[pos..$], closer.toUpper); - if(ending == -1) - throw new Exception("tag " ~ tagName ~ " never closed"); - ending += pos; - e.innerRawSource = data[pos..ending]; - pos = ending + closer.length; + if(ending == -1) { + if(strict) + throw new Exception("tag " ~ tagName ~ " never closed"); + else { + // let's call it totally empty + } + } else { + ending += pos; + e.innerRawSource = data[pos..ending]; + pos = ending + closer.length; + } } return Ele(0, e, null); }