ignore <title> tags in <style> or <script> - grabtitle - stupid HTML title grab… | |
git clone git://git.codemadness.org/grabtitle | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 074560f704de31a111ed6c73edbb1f9c84413aa7 | |
parent 3fae05df6ed35c258c73314f9daa07b92314e03e | |
Author: Hiltjo Posthuma <[email protected]> | |
Date: Tue, 13 Nov 2018 18:06:51 +0100 | |
ignore <title> tags in <style> or <script> | |
seen in the wild web, this prevents an base64-encoded SVG XML inside a <style> | |
tag with a <title> element from being interpreted as a page title. | |
Diffstat: | |
M grabtitle.c | 10 ++++++++-- | |
1 file changed, 8 insertions(+), 2 deletions(-) | |
--- | |
diff --git a/grabtitle.c b/grabtitle.c | |
@@ -15,18 +15,24 @@ | |
#endif | |
static XMLParser parser; | |
-static int istitle; | |
+static int istitle, ignore; | |
static void | |
xmltagstart(XMLParser *p, const char *t, size_t tl) | |
{ | |
- if (tl == 5 && !strcasecmp(t, "title")) | |
+ if ((tl == 6 && !strcasecmp(t, "script")) || | |
+ (tl == 5 && !strcasecmp(t, "style"))) | |
+ ignore = 1; | |
+ if (!ignore && tl == 5 && !strcasecmp(t, "title")) | |
istitle = 1; | |
} | |
static void | |
xmltagend(XMLParser *p, const char *t, size_t tl, int isshort) | |
{ | |
+ if (ignore && ((tl == 6 && !strcasecmp(t, "script")) || | |
+ (tl == 5 && !strcasecmp(t, "style")))) | |
+ ignore = 0; | |
if (istitle && tl == 5 && !strcasecmp(t, "title")) { | |
putchar('\n'); | |
exit(0); |