From 09f1806834629dc292594b1a0dac732aa123a37d Mon Sep 17 00:00:00 2001 From: Geoff McLane Date: Sat, 8 Jul 2017 19:40:47 +0200 Subject: [PATCH] Issue #572 - discard an all space text node. An earlier patch now passes back an all space text node. Previously this would have been skipped. So add code in ParseList to detect, and discard such a node. Change committed: modified: src/parser.c --- src/parser.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/parser.c b/src/parser.c index be07b29..f2c1009 100644 --- a/src/parser.c +++ b/src/parser.c @@ -2475,6 +2475,21 @@ void TY_(ParseList)(TidyDocImpl* doc, Node *list, GetTokenMode ARG_UNUSED(mode)) TY_(FreeNode)( doc, node); continue; } + if (lexer && (node->type == TextNode)) + { + uint ch, ix = node->start; + /* Issue #572 - Skip whitespace. */ + while (ix < node->end && (ch = (lexer->lexbuf[ix] & 0xff)) + && (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n')) + ++ix; + if (ix >= node->end) + { + /* Issue #572 - Discard if ALL whitespace. */ + TY_(FreeNode)(doc, node); + continue; + } + } + /* if this is the end tag for an ancestor element