From a34b0f07b5e45891c3b915e4ff45756d1735c86c Mon Sep 17 00:00:00 2001 From: Jim Derry Date: Fri, 30 Jul 2021 17:15:58 -0400 Subject: [PATCH 1/2] Remove more recursion. --- src/clean.c | 22 ++++++++++++++++++---- src/tidylib.c | 30 ++++++++++++++++++++++++------ 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/src/clean.c b/src/clean.c index e314ba6..e0cd3ba 100644 --- a/src/clean.c +++ b/src/clean.c @@ -1629,6 +1629,7 @@ void TY_(BQ2Div)( TidyDocImpl* doc, Node *node ) node = next ? next : TY_(pop)(stack); } + TY_(freeStack)(stack); } @@ -2591,6 +2592,7 @@ void TY_(ConvertCDATANodes)(TidyDocImpl* doc, Node* node) */ void TY_(FixLanguageInformation)(TidyDocImpl* doc, Node* node, Bool wantXmlLang, Bool wantLang) { + Stack *stack = TY_(newStack)(doc, 16); Node* next; while (node) @@ -2634,10 +2636,15 @@ void TY_(FixLanguageInformation)(TidyDocImpl* doc, Node* node, Bool wantXmlLang, } if (node->content) - TY_(FixLanguageInformation)(doc, node->content, wantXmlLang, wantLang); + { + TY_(push)(stack, next); + node = node->content; + continue; + } - node = next; + node = next ? next : TY_(pop)(stack); } + TY_(freeStack)(stack); } /* @@ -2669,6 +2676,7 @@ void TY_(FixXhtmlNamespace)(TidyDocImpl* doc, Bool wantXmlns) */ void TY_(FixAnchors)(TidyDocImpl* doc, Node *node, Bool wantName, Bool wantId) { + Stack *stack = TY_(newStack)(doc, 16); Node* next; while (node) @@ -2738,10 +2746,15 @@ void TY_(FixAnchors)(TidyDocImpl* doc, Node *node, Bool wantName, Bool wantId) } if (node->content) - TY_(FixAnchors)(doc, node->content, wantName, wantId); + { + TY_(push)(stack, next); + node = node->content; + continue; + } - node = next; + node = next ? next : TY_(pop)(stack); } + TY_(freeStack)(stack); } /* Issue #567 - move style elements from body to head @@ -2785,6 +2798,7 @@ static void StyleToHead(TidyDocImpl* doc, Node *head, Node *node, Bool fix, int indent--; } } + TY_(freeStack)(stack); } diff --git a/src/tidylib.c b/src/tidylib.c index f401323..5907a96 100644 --- a/src/tidylib.c +++ b/src/tidylib.c @@ -1630,15 +1630,19 @@ static Bool nodeHasAlignAttr( Node *node ) */ static void TY_(CheckHTML5)( TidyDocImpl* doc, Node* node ) { + Stack *stack = TY_(newStack)(doc, 16); Bool clean = cfgBool( doc, TidyMakeClean ); Bool already_strict = cfgBool( doc, TidyStrictTagsAttr ); Node* body = TY_(FindBody)( doc ); + Node* next; Bool warn = yes; /* should this be a warning, error, or report??? */ AttVal* attr = NULL; int i = 0; while (node) { + next = node->next; + if ( nodeHasAlignAttr( node ) ) { /* @todo: Is this for ALL elements that accept an 'align' attribute, * or should this be a sub-set test? @@ -1792,10 +1796,15 @@ static void TY_(CheckHTML5)( TidyDocImpl* doc, Node* node ) } if (node->content) - TY_(CheckHTML5)( doc, node->content ); - - node = node->next; + { + TY_(push)(stack, next); + node = node->content; + continue; + } + + node = next ? next : TY_(pop)(stack); } + TY_(freeStack)(stack); } /***************************************************************************** * END HTML5 STUFF @@ -1816,6 +1825,8 @@ static void TY_(CheckHTML5)( TidyDocImpl* doc, Node* node ) */ static void TY_(CheckHTMLTagsAttribsVersions)( TidyDocImpl* doc, Node* node ) { + Stack *stack = TY_(newStack)(doc, 16); + Node *next; uint versionEmitted = doc->lexer->versionEmitted; uint declared = doc->lexer->doctype; uint version = versionEmitted == 0 ? declared : versionEmitted; @@ -1830,6 +1841,8 @@ static void TY_(CheckHTMLTagsAttribsVersions)( TidyDocImpl* doc, Node* node ) while (node) { + next = node->next; + /* This bit here handles our HTML tags */ if ( TY_(nodeIsElement)(node) && node->tag ) { @@ -1914,10 +1927,15 @@ static void TY_(CheckHTMLTagsAttribsVersions)( TidyDocImpl* doc, Node* node ) } if (node->content) - TY_(CheckHTMLTagsAttribsVersions)( doc, node->content ); - - node = node->next; + { + TY_(push)(stack, next); + node = node->content; + continue; + } + + node = next ? next : TY_(pop)(stack); } + TY_(freeStack)(stack); } From b10a16ef1a71cf051f6c5f92d2d8ae1e8e008d75 Mon Sep 17 00:00:00 2001 From: Jim Derry Date: Fri, 30 Jul 2021 17:16:43 -0400 Subject: [PATCH 2/2] Bump to 5.9.6 due to binary differences. --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index 8ff2a58..63c7ba2 100644 --- a/version.txt +++ b/version.txt @@ -1,2 +1,2 @@ -5.9.5 +5.9.6 2021.07.30