diff options
author | rsc <devnull@localhost> | 2006-06-16 15:55:24 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2006-06-16 15:55:24 +0000 |
commit | 9361131304f39db29b1bec59d881e585035ec93c (patch) | |
tree | 811d2c0fa0dcd0b060ee7c53999557402b7ece00 /src/cmd | |
parent | 6884e49f0c8240d40c82553fd60712a28f140ef3 (diff) | |
download | plan9port-9361131304f39db29b1bec59d881e585035ec93c.tar.gz plan9port-9361131304f39db29b1bec59d881e585035ec93c.tar.bz2 plan9port-9361131304f39db29b1bec59d881e585035ec93c.zip |
No more unrooted paths.
Diffstat (limited to 'src/cmd')
-rw-r--r-- | src/cmd/acme/acme.c | 8 | ||||
-rw-r--r-- | src/cmd/acme/look.c | 24 |
2 files changed, 29 insertions, 3 deletions
diff --git a/src/cmd/acme/acme.c b/src/cmd/acme/acme.c index 395033b1..87673cdb 100644 --- a/src/cmd/acme/acme.c +++ b/src/cmd/acme/acme.c @@ -276,11 +276,15 @@ readfile(Column *c, char *s) { Window *w; Rune rb[256]; - int nb, nr; + int nr; Runestr rs; w = coladd(c, nil, nil, -1); - cvttorunes(s, strlen(s), rb, &nb, &nr, nil); + if(s[0] != '/') + runesnprint(rb, sizeof rb, "%s/%s", wdir, s); + else + runesnprint(rb, sizeof rb, "%s", s); + nr = runestrlen(rb); rs = cleanrname(runestr(rb, nr)); winsetname(w, rs.r, rs.nr); textload(&w->body, 0, s, 1); diff --git a/src/cmd/acme/look.c b/src/cmd/acme/look.c index 6abac6ca..a048a353 100644 --- a/src/cmd/acme/look.c +++ b/src/cmd/acme/look.c @@ -696,6 +696,7 @@ openfile(Text *t, Expand *e, int newwindow) Window *w, *ow; int eval, i, n; Rune *rp; + Runestr rs; uint dummy; r.q0 = 0; @@ -704,8 +705,29 @@ openfile(Text *t, Expand *e, int newwindow) w = t->w; if(w == nil) return nil; - }else + }else{ w = lookfile(e->name, e->nname); + if(w == nil && e->name[0] != '/'){ + /* + * Unrooted path in new window. + * This can happen if we type a pwd-relative path + * in the topmost tag or the column tags. + * Most of the time plumber takes care of these, + * but plumber might not be running or might not + * be configured to accept plumbed directories. + * Make the name a full path, just like we would if + * opening via the plumber. + */ + n = utflen(wdir)+1+e->nname+1; + rp = runemalloc(n); + runesnprint(rp, n, "%s/%.*S", wdir, e->nname, e->name); + rs = cleanrname(runestr(rp, n-1)); + free(e->name); + e->name = rs.r; + e->nname = rs.nr; + w = lookfile(e->name, e->nname); + } + } if(w){ if(newwindow==TRUE && !w->isdir) w = coladd(w->col, nil, w, -1); |