From 6d65c4d555edbe1aa0fd91c827676e5aeb74e81c Mon Sep 17 00:00:00 2001 From: Michal Novotny Date: Mon, 21 Sep 2009 19:57:36 +0200 Subject: [PATCH] Bug 214405 - Unable to ftp virtual folder. r=jduell, sr=cbiesinger --- netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp | 2 +- netwerk/streamconv/converters/nsIndexedToHTML.cpp | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp b/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp index e6332e8e0161..b2ee03060e34 100644 --- a/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp +++ b/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp @@ -1507,7 +1507,7 @@ nsFtpState::R_pasv() { mDataStream = do_QueryInterface(input); } - if (mRETRFailed) + if (mRETRFailed || (!mPath.IsEmpty() && mPath.Last() == '/')) return FTP_S_CWD; return FTP_S_SIZE; } diff --git a/netwerk/streamconv/converters/nsIndexedToHTML.cpp b/netwerk/streamconv/converters/nsIndexedToHTML.cpp index a9f9308a31d0..ea1bdcd92425 100644 --- a/netwerk/streamconv/converters/nsIndexedToHTML.cpp +++ b/netwerk/streamconv/converters/nsIndexedToHTML.cpp @@ -899,6 +899,13 @@ nsIndexedToHTML::OnIndexAvailable(nsIRequest *aRequest, NS_ConvertUTF16toUTF8 utf8UnEscapeSpec(unEscapeSpec); + // Adding trailing slash helps to recognize whether the URL points to a file + // or a directory (bug #214405). + if ((type == nsIDirIndex::TYPE_DIRECTORY) && + (utf8UnEscapeSpec.Last() != '/')) { + utf8UnEscapeSpec.Append('/'); + } + // now minimally re-escape the location... PRUint32 escFlags; // for some protocols, like gopher, we expect the location to be absolute. @@ -911,10 +918,9 @@ nsIndexedToHTML::OnIndexAvailable(nsIRequest *aRequest, } else { // escape as relative - // esc_Directory is needed for protocols which allow the same name for - // both a directory and a file and distinguish between the two by a - // trailing '/' -- without it, the trailing '/' will be escaped, and - // links from within that directory will be incorrect + // esc_Directory is needed because directories have a trailing slash. + // Without it, the trailing '/' will be escaped, and links from within + // that directory will be incorrect escFlags = esc_Forced | esc_OnlyASCII | esc_AlwaysCopy | esc_FileBaseName | esc_Colon | esc_Directory; } NS_EscapeURL(utf8UnEscapeSpec.get(), utf8UnEscapeSpec.Length(), escFlags, escapeBuf);