зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
84b88d6276
Коммит
9a77ba2f4a
|
@ -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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче