/*
- * $Id: ftp.cc,v 1.371 2005/09/15 13:38:45 serassio Exp $
+ * $Id: ftp.cc,v 1.372 2005/10/18 19:10:29 serassio Exp $
*
* DEBUG: section 9 File Transfer Protocol (FTP)
* AUTHOR: Harvest Derived
if (ftpState->flags.listformat_unknown && !ftpState->flags.tried_nlst) {
storeAppendPrintf(e, "<A HREF=\"%s/;type=d\">[As plain directory]</A>\n",
- ftpState->flags.dir_slash ? rfc1738_escape_part(ftpState->filepath) : ".");
+ ftpState->flags.dir_slash ? rfc1738_escape_part(ftpState->old_filepath) : ".");
} else if (ftpState->typecode == 'D') {
const char *path = ftpState->flags.dir_slash ? ftpState->filepath : ".";
storeAppendPrintf(e, "<A HREF=\"%s/\">[As extended directory]</A>\n", html_quote(path));
"%2f/",
"Root Directory");
} else if (ftpState->flags.no_dotdot && !ftpState->flags.root_dir) {
+ char *url;
/* Normal directory where last component is / or .. */
strcpy(href, "%2e%2e/");
strcpy(text, "Parent Directory");
- snprintf(link, 2048, "(<A HREF=\"%s\">%s</A>)",
- !ftpState->flags.dir_slash ? "../" : "./",
- "Back");
+
+ if (ftpState->flags.dir_slash) {
+ url = xstrdup("./");
+ } else {
+ const char *title = ftpState->title_url.buf();
+ int k = 6 + strcspn(&title[6], "/");
+ char *t;
+ url = xstrdup(title + k);
+ t = url + strlen(url) - 2;
+
+ while (t > url && *t != '/')
+ *t-- = '\0';
+ }
+
+ snprintf(link, 2048, "(<A HREF=\"%s\">%s</A>)", url, "Back");
+ safe_free(url);
} else { /* NO_DOTDOT && ROOT_DIR */
/* "UNIX Root" directory */
strcpy(href, "/");
if (l == 1)
ftpState->flags.root_dir = 1;
+ } else {
+ ftpState->flags.dir_slash = 1;
}
}
static void
ftpListDir(FtpStateData * ftpState)
{
- if (!ftpState->flags.isdir) {
+ if (ftpState->flags.dir_slash) {
debug(9, 3) ("Directory path did not end in /\n");
ftpState->title_url.append("/");
ftpState->flags.isdir = 1;
- ftpState->flags.dir_slash = 1;
}
ftpSendPasv(ftpState);