form->method = (char *)xmlGetProp(xml_node, (unsigned char *)"method");
form->action = (char *)xmlGetProp(xml_node, (unsigned char *)"action");
if (!form->method || !form->action ||
- strcasecmp(form->method, "POST") || form->action[0] != '/') {
+ strcasecmp(form->method, "POST") || !form->action[0]) {
vpninfo->progress(vpninfo, PRG_ERR,
"Cannot handle form method='%s', action='%s'\n",
form->method, form->action);
vpninfo->redirect_url = NULL;
goto retry;
} else {
- vpninfo->progress(vpninfo, PRG_ERR, "Relative redirect (to '%s') not supported\n",
- vpninfo->redirect_url);
- free(form_buf);
- return -EINVAL;
+ char *lastslash = strrchr(vpninfo->urlpath, '/');
+ if (!lastslash) {
+ free(vpninfo->urlpath);
+ vpninfo->urlpath = vpninfo->redirect_url;
+ vpninfo->redirect_url = NULL;
+ } else {
+ char *oldurl = vpninfo->urlpath;
+ *lastslash = 0;
+ vpninfo->urlpath = NULL;
+ if (asprintf(&vpninfo->urlpath, "%s/%s",
+ oldurl, vpninfo->redirect_url) == -1) {
+ int err = -errno;
+ vpninfo->progress(vpninfo, PRG_ERR,
+ "Allocating new path for relative redirect failed: %s\n",
+ strerror(-err));
+ return err;
+ }
+ free(oldurl);
+ free(vpninfo->redirect_url);
+ vpninfo->redirect_url = NULL;
+ }
+ goto retry;
}
}