diff options
author | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-07-17 07:21:22 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-07-17 07:21:22 +0200 |
commit | a78f5f8a3d72fc18c9bb734e066f45e9a3be5ab0 (patch) | |
tree | b1259e1089a2287f5e35d7c52f2ff3365bb6ba3c /sys/src | |
parent | 05c11fefe0c633ab061b9f69180593ed9cf073a2 (diff) |
mothra: handle relative urls in <base> tag
Diffstat (limited to 'sys/src')
-rw-r--r-- | sys/src/cmd/mothra/mothra.h | 1 | ||||
-rw-r--r-- | sys/src/cmd/mothra/rdhtml.c | 6 | ||||
-rw-r--r-- | sys/src/cmd/mothra/url.c | 17 |
3 files changed, 23 insertions, 1 deletions
diff --git a/sys/src/cmd/mothra/mothra.h b/sys/src/cmd/mothra/mothra.h index ecae06972..e56b11ea7 100644 --- a/sys/src/cmd/mothra/mothra.h +++ b/sys/src/cmd/mothra/mothra.h @@ -102,5 +102,6 @@ void mkfieldpanel(Rtext *); void geturl(char *, int, int, int); int urlpost(Url*, char*); int urlget(Url*, int); +int urlresolve(Url *); char version[]; Mouse mouse; diff --git a/sys/src/cmd/mothra/rdhtml.c b/sys/src/cmd/mothra/rdhtml.c index be8378dbd..201959762 100644 --- a/sys/src/cmd/mothra/rdhtml.c +++ b/sys/src/cmd/mothra/rdhtml.c @@ -734,8 +734,12 @@ void plrdhtml(char *name, int fd, Www *dst){ g.spacc++; break; case Tag_base: - if(str=pl_getattr(g.attr, "href")) + if(str=pl_getattr(g.attr, "href")){ + seturl(g.dst->url, str, g.dst->url->fullname); nstrcpy(g.dst->url->fullname, str, sizeof(g.dst->url->fullname)); + /* base should be a full url, but it often isnt so have to resolve */ + urlresolve(g.dst->url); + } break; case Tag_a: if(str=pl_getattr(g.attr, "name")) diff --git a/sys/src/cmd/mothra/url.c b/sys/src/cmd/mothra/url.c index 014cb2c1d..5bb4736b9 100644 --- a/sys/src/cmd/mothra/url.c +++ b/sys/src/cmd/mothra/url.c @@ -151,3 +151,20 @@ urlget(Url *url, int body) return fd; } + +int +urlresolve(Url *url) +{ + char buf[1024]; + int n, fd; + + if((fd = webclone(url, buf, sizeof(buf))) < 0) + return -1; + n = strlen(buf); + snprint(buf+n, sizeof(buf)-n, "/parsed/url"); + readstr(buf, url->fullname, sizeof(url->fullname)); + snprint(buf+n, sizeof(buf)-n, "/parsed/fragment"); + readstr(buf, url->tag, sizeof(url->tag)); + close(fd); + return 0; +} |