summaryrefslogtreecommitdiff
path: root/sys/src/cmd/mothra
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2012-08-16 09:03:57 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2012-08-16 09:03:57 +0200
commit81954dbf2535b3ae65acabee5f6210d8a002a9a8 (patch)
tree92e838a90ce4a4a46f57992e16be2c9e4250c540 /sys/src/cmd/mothra
parent2dd17995f1241c8e5b019d7118234257b17c0920 (diff)
mothra: bruteforce image src= attribute
Diffstat (limited to 'sys/src/cmd/mothra')
-rw-r--r--sys/src/cmd/mothra/rdhtml.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/sys/src/cmd/mothra/rdhtml.c b/sys/src/cmd/mothra/rdhtml.c
index 32b327aff..a4dff1089 100644
--- a/sys/src/cmd/mothra/rdhtml.c
+++ b/sys/src/cmd/mothra/rdhtml.c
@@ -264,6 +264,8 @@ int entchar(int c){
/* 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 @@ void plrdhtml(char *name, int fd, Www *dst){
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);