summaryrefslogtreecommitdiffstats
path: root/parser/html/javasrc
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-09-04 15:27:40 +0200
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-09-04 15:27:40 +0200
commit0ce08b418d84a57bae22a0aa395fecb7412ed931 (patch)
tree7d46a9b019e57aee76879290695ce2173a8891af /parser/html/javasrc
parentcc60a093cb65745602dc1f5eab9f5e328ddaad15 (diff)
downloadUXP-0ce08b418d84a57bae22a0aa395fecb7412ed931.tar
UXP-0ce08b418d84a57bae22a0aa395fecb7412ed931.tar.gz
UXP-0ce08b418d84a57bae22a0aa395fecb7412ed931.tar.lz
UXP-0ce08b418d84a57bae22a0aa395fecb7412ed931.tar.xz
UXP-0ce08b418d84a57bae22a0aa395fecb7412ed931.zip
Fix an issue with the html5 tokenizer and tree builder.
Diffstat (limited to 'parser/html/javasrc')
-rw-r--r--parser/html/javasrc/Tokenizer.java33
-rw-r--r--parser/html/javasrc/TreeBuilder.java22
2 files changed, 37 insertions, 18 deletions
diff --git a/parser/html/javasrc/Tokenizer.java b/parser/html/javasrc/Tokenizer.java
index 70e1df75c..f141d94d7 100644
--- a/parser/html/javasrc/Tokenizer.java
+++ b/parser/html/javasrc/Tokenizer.java
@@ -1,6 +1,7 @@
/*
* Copyright (c) 2005-2007 Henri Sivonen
* Copyright (c) 2007-2015 Mozilla Foundation
+ * Copyright (c) 2019 Moonchild Productions
* Portions of comments Copyright 2004-2010 Apple Computer, Inc., Mozilla
* Foundation, and Opera Software ASA.
*
@@ -680,6 +681,22 @@ public class Tokenizer implements Locator {
*
* @param specialTokenizerState
* the tokenizer state to set
+ */
+ public void setState(int specialTokenizerState) {
+ this.stateSave = specialTokenizerState;
+ this.endTagExpectation = null;
+ this.endTagExpectationAsArray = null;
+ }
+
+ // [NOCPP[
+
+ /**
+ * Sets the tokenizer state and the associated element name. This should
+ * only ever used to put the tokenizer into one of the states that have
+ * a special end tag expectation. For use from the tokenizer test harness.
+ *
+ * @param specialTokenizerState
+ * the tokenizer state to set
* @param endTagExpectation
* the expected end tag for transitioning back to normal
*/
@@ -695,6 +712,8 @@ public class Tokenizer implements Locator {
endTagExpectationToArray();
}
+ // ]NOCPP]
+
/**
* Sets the tokenizer state and the associated element name. This should
* only ever used to put the tokenizer into one of the states that have
@@ -3759,11 +3778,17 @@ public class Tokenizer implements Locator {
c = checkChar(buf, pos);
/*
* ASSERT! when entering this state, set index to 0 and
- * call clearStrBufBeforeUse() assert (contentModelElement !=
- * null); Let's implement the above without lookahead.
- * strBuf is the 'temporary buffer'.
+ * call clearStrBufBeforeUse(); Let's implement the above
+ * without lookahead. strBuf is the 'temporary buffer'.
*/
- if (index < endTagExpectationAsArray.length) {
+ if (endTagExpectationAsArray == null) {
+ tokenHandler.characters(Tokenizer.LT_SOLIDUS,
+ 0, 2);
+ cstart = pos;
+ reconsume = true;
+ state = transition(state, returnState, reconsume, pos);
+ continue stateloop;
+ } else if (index < endTagExpectationAsArray.length) {
char e = endTagExpectationAsArray[index];
char folded = c;
if (c >= 'A' && c <= 'Z') {
diff --git a/parser/html/javasrc/TreeBuilder.java b/parser/html/javasrc/TreeBuilder.java
index 5e83d1847..58074086d 100644
--- a/parser/html/javasrc/TreeBuilder.java
+++ b/parser/html/javasrc/TreeBuilder.java
@@ -1,6 +1,7 @@
/*
* Copyright (c) 2007 Henri Sivonen
* Copyright (c) 2007-2015 Mozilla Foundation
+ * Copyright (c) 2018-2019 Moonchild Productions
* Portions of comments Copyright 2004-2008 Apple Computer, Inc., Mozilla
* Foundation, and Opera Software ASA.
*
@@ -640,8 +641,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
);
currentPtr++;
stack[currentPtr] = node;
- tokenizer.setStateAndEndTagExpectation(Tokenizer.DATA,
- contextName);
+ tokenizer.setState(Tokenizer.DATA);
// The frameset-ok flag is set even though <frameset> never
// ends up being allowed as HTML frameset in the fragment case.
mode = FRAMESET_OK;
@@ -671,8 +671,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
);
currentPtr++;
stack[currentPtr] = node;
- tokenizer.setStateAndEndTagExpectation(Tokenizer.DATA,
- contextName);
+ tokenizer.setState(Tokenizer.DATA);
// The frameset-ok flag is set even though <frameset> never
// ends up being allowed as HTML frameset in the fragment case.
mode = FRAMESET_OK;
@@ -691,23 +690,18 @@ public abstract class TreeBuilder<T> implements TokenHandler,
resetTheInsertionMode();
formPointer = getFormPointerForContext(contextNode);
if ("title" == contextName || "textarea" == contextName) {
- tokenizer.setStateAndEndTagExpectation(Tokenizer.RCDATA,
- contextName);
+ tokenizer.setState(Tokenizer.RCDATA);
} else if ("style" == contextName || "xmp" == contextName
|| "iframe" == contextName || "noembed" == contextName
|| "noframes" == contextName
|| (scriptingEnabled && "noscript" == contextName)) {
- tokenizer.setStateAndEndTagExpectation(Tokenizer.RAWTEXT,
- contextName);
+ tokenizer.setState(Tokenizer.RAWTEXT);
} else if ("plaintext" == contextName) {
- tokenizer.setStateAndEndTagExpectation(Tokenizer.PLAINTEXT,
- contextName);
+ tokenizer.setState(Tokenizer.PLAINTEXT);
} else if ("script" == contextName) {
- tokenizer.setStateAndEndTagExpectation(
- Tokenizer.SCRIPT_DATA, contextName);
+ tokenizer.setState(Tokenizer.SCRIPT_DATA);
} else {
- tokenizer.setStateAndEndTagExpectation(Tokenizer.DATA,
- contextName);
+ tokenizer.setState(Tokenizer.DATA);
}
}
contextName = null;