diff --git a/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp b/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp index cb7a43e239e..14a58db48af 100644 --- a/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp +++ b/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp @@ -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 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)); } diff --git a/netwerk/streamconv/converters/nsIndexedToHTML.cpp b/netwerk/streamconv/converters/nsIndexedToHTML.cpp index 3e621986633..a93e84c68af 100644 --- a/netwerk/streamconv/converters/nsIndexedToHTML.cpp +++ b/netwerk/streamconv/converters/nsIndexedToHTML.cpp @@ -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;