mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
Bug 555899 - Make the HTML5 parser have a limit of 200 on the stack depth like the old parser. rs=sicking.
This commit is contained in:
parent
282e0eeb8c
commit
63a2095f47
@ -60,6 +60,8 @@ import org.xml.sax.SAXParseException;
|
||||
public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
TreeBuilderState<T> {
|
||||
|
||||
public static final int STACK_MAX_DEPTH = 200;
|
||||
|
||||
// Start dispatch groups
|
||||
|
||||
final static int OTHER = 0;
|
||||
@ -4176,6 +4178,10 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked") private void push(StackNode<T> node) throws SAXException {
|
||||
if (currentPtr == TreeBuilder.STACK_MAX_DEPTH) {
|
||||
warn("Maximum depth for tree builder stack reached. Modifying document.");
|
||||
pop();
|
||||
}
|
||||
currentPtr++;
|
||||
if (currentPtr == stack.length) {
|
||||
StackNode<T>[] newStack = new StackNode[stack.length + 64];
|
||||
@ -4188,6 +4194,10 @@ public abstract class TreeBuilder<T> implements TokenHandler,
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked") private void silentPush(StackNode<T> node) throws SAXException {
|
||||
if (currentPtr == TreeBuilder.STACK_MAX_DEPTH) {
|
||||
warn("Maximum depth for tree builder stack reached. Modifying document.");
|
||||
pop();
|
||||
}
|
||||
currentPtr++;
|
||||
if (currentPtr == stack.length) {
|
||||
StackNode<T>[] newStack = new StackNode[stack.length + 64];
|
||||
|
@ -3062,6 +3062,10 @@ nsHtml5TreeBuilder::clearLastListSlot()
|
||||
void
|
||||
nsHtml5TreeBuilder::push(nsHtml5StackNode* node)
|
||||
{
|
||||
if (currentPtr == NS_HTML5TREE_BUILDER_STACK_MAX_DEPTH) {
|
||||
|
||||
pop();
|
||||
}
|
||||
currentPtr++;
|
||||
if (currentPtr == stack.length) {
|
||||
jArray<nsHtml5StackNode*,PRInt32> newStack = jArray<nsHtml5StackNode*,PRInt32>(stack.length + 64);
|
||||
@ -3076,6 +3080,10 @@ nsHtml5TreeBuilder::push(nsHtml5StackNode* node)
|
||||
void
|
||||
nsHtml5TreeBuilder::silentPush(nsHtml5StackNode* node)
|
||||
{
|
||||
if (currentPtr == NS_HTML5TREE_BUILDER_STACK_MAX_DEPTH) {
|
||||
|
||||
pop();
|
||||
}
|
||||
currentPtr++;
|
||||
if (currentPtr == stack.length) {
|
||||
jArray<nsHtml5StackNode*,PRInt32> newStack = jArray<nsHtml5StackNode*,PRInt32>(stack.length + 64);
|
||||
|
@ -243,6 +243,7 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
|
||||
jArray<const char*,PRInt32> nsHtml5TreeBuilder::QUIRKY_PUBLIC_IDS = nsnull;
|
||||
#endif
|
||||
|
||||
#define NS_HTML5TREE_BUILDER_STACK_MAX_DEPTH 200
|
||||
#define NS_HTML5TREE_BUILDER_OTHER 0
|
||||
#define NS_HTML5TREE_BUILDER_A 1
|
||||
#define NS_HTML5TREE_BUILDER_BASE 2
|
||||
|
Loading…
Reference in New Issue
Block a user