ref: ed0fa0e48e578ae791e939d89191683ff6a8c30d
parent: bd41e7883899de65175121288aaf972326b55bef
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Thu Aug 16 05:03:57 EDT 2012
mothra: bruteforce image src= attribute
--- a/sys/src/cmd/mothra/rdhtml.c
+++ b/sys/src/cmd/mothra/rdhtml.c
@@ -264,6 +264,8 @@
/* return url if text token looks like a hyperlink */
char *linkify(char *s){+ if(s == 0 && s[0] == 0)
+ return 0;
if(!cistrncmp(s, "http://", 7))
return strdup(s);
if(!cistrncmp(s, "https://", 8))
@@ -701,6 +703,24 @@
case Tag_img:
if(str=pl_getattr(g.attr, "src"))
nstrcpy(g.state->image, str, sizeof(g.state->image));
+ else {+ Pair *a;
+
+ /*
+ * hack to emulate javascript that rewrites some attribute
+ * into src= after page got loaded. just look for some
+ * attribute that looks like a url.
+ */
+ for(a = g.attr; a->name; a++){+ if(strcmp(a->name, "longdesc") == 0)
+ continue;
+ if(str = linkify(a->value)){+ nstrcpy(g.state->image, str, sizeof(g.state->image));
+ free(str);
+ break;
+ }
+ }
+ }
g.state->ismap=pl_hasattr(g.attr, "ismap");
if(str=pl_getattr(g.attr, "width"))
g.state->width=strtolength(&g, HORIZ, str);
--
⑨