Bug 391855 - "FTP directory URL without a trailing slash can result in files being uploaded to the wrong place" [p=wgianopoulos@yahoo.com (Bill Gianopoulos) r=dougt sr=biesi aM9=beltzner]

This commit is contained in:
reed%reedloden.com 2007-11-05 21:02:53 +00:00
Родитель f30ed283a4
Коммит 59c12a4045
2 изменённых файлов: 18 добавлений и 14 удалений

Просмотреть файл

@ -1044,6 +1044,20 @@ nsFtpState::R_mdtm() {
nsresult
nsFtpState::SetContentType()
{
// FTP directory URLs don't always end in a slash. Make sure they do.
// This check needs to be here rather than a more obvious place
// (e.g. LIST command processing) so that it ensures the terminating
// slash is appended for the new request case, as well as the case
// where the URL is being loaded from the cache.
if (!mPath.IsEmpty() && mPath.Last() != '/') {
nsCOMPtr<nsIURL> url = (do_QueryInterface(mChannel->URI()));
nsCAutoString filePath;
if(NS_SUCCEEDED(url->GetFilePath(filePath))) {
filePath.Append('/');
url->SetFilePath(filePath);
}
}
return mChannel->SetContentType(
NS_LITERAL_CSTRING(APPLICATION_HTTP_INDEX_FORMAT));
}

Просмотреть файл

@ -166,18 +166,6 @@ nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) {
PRBool isSchemeGopher = PR_FALSE;
if (NS_SUCCEEDED(uri->SchemeIs("ftp", &isScheme)) && isScheme) {
// ftp urls don't always end in a /
// make sure they do
// but look out for /%2F as path
nsCAutoString path;
rv = uri->GetPath(path);
if (NS_FAILED(rv)) return rv;
if (baseUri.Last() != '/' && !path.LowerCaseEqualsLiteral("/%2f")) {
baseUri.Append('/');
path.Append('/');
uri->SetPath(path);
}
// strip out the password here, so it doesn't show in the page title
// This is done by the 300: line generation in ftp, but we don't use
// that - see above
@ -193,10 +181,12 @@ nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) {
if (NS_FAILED(rv)) return rv;
rv = newUri->GetAsciiSpec(titleUri);
if (NS_FAILED(rv)) return rv;
if (titleUri.Last() != '/' && !path.LowerCaseEqualsLiteral("/%2f"))
titleUri.Append('/');
}
nsCAutoString path;
rv = uri->GetPath(path);
if (NS_FAILED(rv)) return rv;
if (!path.EqualsLiteral("//") && !path.LowerCaseEqualsLiteral("/%2f")) {
rv = uri->Resolve(NS_LITERAL_CSTRING(".."),parentStr);
if (NS_FAILED(rv)) return rv;