mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 942791 - Revert bug 427089. r=mayhemer
This commit is contained in:
parent
5bad48704a
commit
45395c7ee6
@ -30,7 +30,6 @@
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsAuthInformationHolder.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsIProtocolProxyService.h"
|
||||
#include "nsICancelable.h"
|
||||
#include "nsICacheEntryDescriptor.h"
|
||||
@ -1742,12 +1741,6 @@ nsFtpState::Init(nsFtpChannel *channel)
|
||||
// now unescape it... %xx reduced inline to resulting character
|
||||
int32_t len = NS_UnescapeURL(fwdPtr);
|
||||
mPath.Assign(fwdPtr, len);
|
||||
if (IsUTF8(mPath)) {
|
||||
nsAutoCString originCharset;
|
||||
rv = mChannel->URI()->GetOriginCharset(originCharset);
|
||||
if (NS_SUCCEEDED(rv) && !originCharset.EqualsLiteral("UTF-8"))
|
||||
ConvertUTF8PathToCharset(originCharset);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (mPath.FindCharInSet(CRLF) >= 0)
|
||||
@ -2455,58 +2448,3 @@ nsFtpState::CheckCache()
|
||||
return NS_SUCCEEDED(rv);
|
||||
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFtpState::ConvertUTF8PathToCharset(const nsACString &aCharset)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_ASSERTION(IsUTF8(mPath), "mPath isn't UTF8 string!");
|
||||
NS_ConvertUTF8toUTF16 ucsPath(mPath);
|
||||
nsAutoCString result;
|
||||
|
||||
nsCOMPtr<nsICharsetConverterManager> charsetMgr(
|
||||
do_GetService("@mozilla.org/charset-converter-manager;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIUnicodeEncoder> encoder;
|
||||
rv = charsetMgr->GetUnicodeEncoder(PromiseFlatCString(aCharset).get(),
|
||||
getter_AddRefs(encoder));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
int32_t len = ucsPath.Length();
|
||||
int32_t maxlen;
|
||||
|
||||
rv = encoder->GetMaxLength(ucsPath.get(), len, &maxlen);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
char buf[256], *p = buf;
|
||||
if (uint32_t(maxlen) > sizeof(buf) - 1) {
|
||||
p = (char *) malloc(maxlen + 1);
|
||||
if (!p)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
rv = encoder->Convert(ucsPath.get(), &len, p, &maxlen);
|
||||
if (NS_FAILED(rv))
|
||||
goto end;
|
||||
if (rv == NS_ERROR_UENC_NOMAPPING) {
|
||||
NS_WARNING("unicode conversion failed");
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
goto end;
|
||||
}
|
||||
p[maxlen] = 0;
|
||||
result.Assign(p);
|
||||
|
||||
len = sizeof(buf) - 1;
|
||||
rv = encoder->Finish(buf, &len);
|
||||
if (NS_FAILED(rv))
|
||||
goto end;
|
||||
buf[len] = 0;
|
||||
result.Append(buf);
|
||||
mPath = result;
|
||||
|
||||
end:
|
||||
if (p != buf)
|
||||
free(p);
|
||||
return rv;
|
||||
}
|
||||
|
@ -144,7 +144,6 @@ private:
|
||||
void ConvertDirspecFromVMS(nsCString& fileSpec);
|
||||
nsresult BuildStreamConverter(nsIStreamListener** convertStreamListener);
|
||||
nsresult SetContentType();
|
||||
nsresult ConvertUTF8PathToCharset(const nsACString &aCharset);
|
||||
|
||||
/**
|
||||
* This method is called to kick-off the FTP state machine. mState is
|
||||
|
Loading…
Reference in New Issue
Block a user