aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authornyamatongwe <unknown>2009-02-15 00:39:16 +0000
committernyamatongwe <unknown>2009-02-15 00:39:16 +0000
commite8b2835c129ed63fa37e5588382195a6c794f426 (patch)
treececcadd1fff3b71942180ad36a9c954d0168f583 /src
parent462ea92449cb49fbbe1c6eaa7dfe3d109eaf88d1 (diff)
downloadscintilla-mirror-e8b2835c129ed63fa37e5588382195a6c794f426.tar.gz
Bug #1843242 partial fix from Kai Liu prevents script state when script tag
is self closed.
Diffstat (limited to 'src')
-rw-r--r--src/LexHTML.cxx19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/LexHTML.cxx b/src/LexHTML.cxx
index 6d16c53f9..c324a1437 100644
--- a/src/LexHTML.cxx
+++ b/src/LexHTML.cxx
@@ -274,17 +274,30 @@ static int classifyTagHTML(unsigned int start, unsigned int end,
s[i] = '\0';
// No keywords -> all are known
- // Name of a closing tag starts at s + 1
char chAttr = SCE_H_TAGUNKNOWN;
if (s[0] == '!') {
chAttr = SCE_H_SGML_DEFAULT;
- } else if (!keywords || keywords.InList(s[0] == '/' ? s + 1 : s)) {
+ } else if (!keywords || keywords.InList(s)) {
chAttr = SCE_H_TAG;
}
styler.ColourTo(end, chAttr);
if (chAttr == SCE_H_TAG) {
if (allowScripts && 0 == strcmp(s, "script")) {
- chAttr = SCE_H_SCRIPT;
+ // check to see if this is a self-closing tag by sniffing ahead
+ bool isSelfClose = false;
+ for (unsigned int cPos = end; cPos <= end + 100; cPos++) {
+ char ch = styler.SafeGetCharAt(cPos, '\0');
+ if (ch == '\0' || ch == '>')
+ break;
+ else if (ch == '/' && styler.SafeGetCharAt(cPos + 1, '\0') == '>') {
+ isSelfClose = true;
+ break;
+ }
+ }
+
+ // do not enter a script state if the tag self-closed
+ if (!isSelfClose)
+ chAttr = SCE_H_SCRIPT;
} else if (!isXml && 0 == strcmp(s, "comment")) {
chAttr = SCE_H_COMMENT;
}