webfs: fix url fragment bug, preserve fragment on redirect

This commit is contained in:
cinap_lenrek 2011-10-13 18:12:55 +02:00
parent 46ecc9eff6
commit e02b84087e
2 changed files with 7 additions and 2 deletions

View file

@ -73,7 +73,7 @@ clonectl(Ctl *c)
void
clientbodyopen(Client *c, Req *r)
{
char e[ERRMAX], *next;
char e[ERRMAX], *next, *frag;
int i, nauth;
Url *u;
@ -116,6 +116,11 @@ clientbodyopen(Client *c, Req *r)
}
if((u = parseurl(next, c->url)) == nil)
goto Error;
/* if there was a redirect, carry over the fragment */
if((frag = c->url->fragment) && u->fragment == nil){
u->fragment = estrdup(frag);
rewriteurl(u);
}
if(urldebug)
fprint(2, "parseurl %s got scheme %d\n", next, u->ischeme);
if(u->ischeme == USunknown){

View file

@ -434,7 +434,7 @@ resolve_relative(SplitUrl *su, Url *base, Url *u)
if(su->fragment.s){
*purl++ = '#';
memmove(purl, su->query.s, su->query.e - su->query.s);
memmove(purl, su->fragment.s, su->fragment.e - su->fragment.s);
purl += su->fragment.e - su->fragment.s;
}else if(currentdoc && base->fragment){
*purl++ = '#';