timprove hidden elements, add "hidden" and "aria-hidden" attribute parsing - webdump - [FORK] git://git.codemadness.org/webdump
(HTM) git clone git://git.z3bra.org/webdump.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 2ef6d5a9e0fb526243121a4ac99f97f22ae6cd1a
(DIR) parent a7a2ba6114f500856fbe532006fb15d9a18f5e2f
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Mon, 9 Dec 2019 19:05:44 +0100
improve hidden elements, add "hidden" and "aria-hidden" attribute parsing
Diffstat:
M webdump.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
---
(DIR) diff --git a/webdump.c b/webdump.c
t@@ -693,6 +693,8 @@ xmltagstartparsed(XMLParser *p, const char *t, size_t tl, int isshort)
}
cur = &nodes[curnode];
+ if (cur->tag.displaytype & DisplayNone)
+ return;
/* show links as reference at the bottom */
if (showlinkrefs && src[0]) {
t@@ -781,6 +783,17 @@ xmlattr(XMLParser *p, const char *tag, size_t taglen, const char *name,
{
struct node *cur;
+ cur = &nodes[curnode];
+ if (cur->tag.displaytype & DisplayNone)
+ return;
+
+ /* hide tags with attribute aria-hidden or hidden */
+ if (!strcasecmp(name, "aria-hidden") || !strcasecmp(name, "hidden"))
+ cur->tag.displaytype |= DisplayNone;
+
+ if (cur->tag.displaytype & DisplayNone)
+ return;
+
if (!strcasecmp(tag, "a") && !strcasecmp(name, "href") && valuelen)
strlcpy(src, value, sizeof(src));
t@@ -789,9 +802,6 @@ xmlattr(XMLParser *p, const char *tag, size_t taglen, const char *name,
!strcasecmp(name, "src") && valuelen)
strlcpy(src, value, sizeof(src));
- cur = &nodes[curnode];
- if (cur->tag.displaytype & DisplayNone)
- return;
/* show img alt attribute as text. */
if (!strcasecmp(tag, "img") && !strcasecmp(name, "alt"))
printsafe(value, strlen(value));