summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@centraldogma>2011-09-17 01:13:27 +0200
committercinap_lenrek <cinap_lenrek@centraldogma>2011-09-17 01:13:27 +0200
commit827b20563b1448306dc9cfd7afdef6fd0e32ad35 (patch)
tree179e5cf9fd1808715aaa35d0868c49cd32130970
parentb622d928912018951b333d6f7e002fa83a71d3cd (diff)
downloadplan9front-827b20563b1448306dc9cfd7afdef6fd0e32ad35.tar.xz
mothra: fix charset handling and url snarfing
-rw-r--r--sys/src/cmd/mothra/mothra.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/sys/src/cmd/mothra/mothra.c b/sys/src/cmd/mothra/mothra.c
index f659dffd3..ef51ee2d0 100644
--- a/sys/src/cmd/mothra/mothra.c
+++ b/sys/src/cmd/mothra/mothra.c
@@ -743,7 +743,7 @@ int fileurlopen(Url *url){
int urlopen(Url *url, int method, char *body){
int conn, ctlfd, fd, n;
- char buf[1024+1];
+ char buf[1024+1], *p;
if(debug) fprint(2, "urlopen %s (%s)\n", url->reltext, url->basename);
@@ -794,6 +794,15 @@ int urlopen(Url *url, int method, char *body){
snprint(buf, sizeof buf, "%s/%d", mtpt, conn);
readstr(buf, sizeof buf, buf, "contenttype");
+ url->charset[0] = 0;
+ if(p = cistrstr(buf, "charset=")){
+ p += 8;
+ strncpy(url->charset, p, sizeof(url->charset));
+ if(p = strchr(url->charset, ';'))
+ *p = 0;
+ }
+ if(p = strchr(buf, ';'))
+ *p = 0;
url->type = content2type(buf, url->fullname);
close(ctlfd);
@@ -977,7 +986,7 @@ void snarf(Panel *p){
int fd;
fd=create("/dev/snarf", OWRITE, 0666);
if(fd>=0){
- fprint(fd, "%s", selection->fullname);
+ fprint(fd, "%s", selection->fullname[0] ? selection->fullname : selection->reltext);
close(fd);
}
}