mshtml: Always use UTF-8 encoding in nsWineURL.

This commit is contained in:
Jacek Caban 2012-11-21 15:06:34 +01:00 committed by Alexandre Julliard
parent 841214ddb4
commit d202daa182
2 changed files with 47 additions and 17 deletions

View File

@ -1102,6 +1102,36 @@ static inline char *heap_strdupWtoA(LPCWSTR str)
return ret; return ret;
} }
static inline WCHAR *heap_strdupUtoW(const char *str)
{
WCHAR *ret = NULL;
if(str) {
size_t len;
len = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0);
ret = heap_alloc(len*sizeof(WCHAR));
if(ret)
MultiByteToWideChar(CP_UTF8, 0, str, -1, ret, len);
}
return ret;
}
static inline char *heap_strdupWtoU(const WCHAR *str)
{
char *ret = NULL;
if(str) {
size_t size = WideCharToMultiByte(CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL);
ret = heap_alloc(size);
if(ret)
WideCharToMultiByte(CP_UTF8, 0, str, -1, ret, size, NULL, NULL);
}
return ret;
}
static inline void windowref_addref(windowref_t *ref) static inline void windowref_addref(windowref_t *ref)
{ {
InterlockedIncrement(&ref->ref); InterlockedIncrement(&ref->ref);

View File

@ -162,12 +162,12 @@ static nsresult return_wstr_nsacstr(nsACString *ret_str, const WCHAR *str, int l
return NS_OK; return NS_OK;
} }
lena = WideCharToMultiByte(CP_ACP, 0, str, len, NULL, 0, NULL, NULL); lena = WideCharToMultiByte(CP_UTF8, 0, str, len, NULL, 0, NULL, NULL);
stra = heap_alloc(lena+1); stra = heap_alloc(lena+1);
if(!stra) if(!stra)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
WideCharToMultiByte(CP_ACP, 0, str, len, stra, lena, NULL, NULL); WideCharToMultiByte(CP_UTF8, 0, str, len, stra, lena, NULL, NULL);
stra[lena] = 0; stra[lena] = 0;
nsACString_SetData(ret_str, stra); nsACString_SetData(ret_str, stra);
@ -1769,7 +1769,7 @@ static nsresult get_uri_string(nsWineURI *This, Uri_PROPERTY prop, nsACString *r
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }
vala = heap_strdupWtoA(val); vala = heap_strdupWtoU(val);
SysFreeString(val); SysFreeString(val);
if(!vala) if(!vala)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -1876,7 +1876,7 @@ static nsresult NSAPI nsURI_SetSpec(nsIFileURL *iface, const nsACString *aSpec)
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
nsACString_GetData(aSpec, &speca); nsACString_GetData(aSpec, &speca);
spec = heap_strdupAtoW(speca); spec = heap_strdupUtoW(speca);
if(!spec) if(!spec)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -1942,7 +1942,7 @@ static nsresult NSAPI nsURI_SetScheme(nsIFileURL *iface, const nsACString *aSche
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
nsACString_GetData(aScheme, &schemea); nsACString_GetData(aScheme, &schemea);
scheme = heap_strdupAtoW(schemea); scheme = heap_strdupUtoW(schemea);
if(!scheme) if(!scheme)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -2002,7 +2002,7 @@ static nsresult NSAPI nsURI_SetUserPass(nsIFileURL *iface, const nsACString *aUs
if(*user_pass) { if(*user_pass) {
WCHAR *ptr; WCHAR *ptr;
buf = heap_strdupAtoW(user_pass); buf = heap_strdupUtoW(user_pass);
if(!buf) if(!buf)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -2049,7 +2049,7 @@ static nsresult NSAPI nsURI_SetUsername(nsIFileURL *iface, const nsACString *aUs
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
nsACString_GetData(aUsername, &usera); nsACString_GetData(aUsername, &usera);
user = heap_strdupAtoW(usera); user = heap_strdupUtoW(usera);
if(!user) if(!user)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -2083,7 +2083,7 @@ static nsresult NSAPI nsURI_SetPassword(nsIFileURL *iface, const nsACString *aPa
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
nsACString_GetData(aPassword, &passa); nsACString_GetData(aPassword, &passa);
pass = heap_strdupAtoW(passa); pass = heap_strdupUtoW(passa);
if(!pass) if(!pass)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -2118,7 +2118,7 @@ static nsresult NSAPI nsURI_GetHostPort(nsIFileURL *iface, nsACString *aHostPort
if(!ptr) if(!ptr)
ptr = val; ptr = val;
vala = heap_strdupWtoA(ptr); vala = heap_strdupWtoU(ptr);
SysFreeString(val); SysFreeString(val);
if(!vala) if(!vala)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -2161,7 +2161,7 @@ static nsresult NSAPI nsURI_SetHost(nsIFileURL *iface, const nsACString *aHost)
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
nsACString_GetData(aHost, &hosta); nsACString_GetData(aHost, &hosta);
host = heap_strdupAtoW(hosta); host = heap_strdupUtoW(hosta);
if(!host) if(!host)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -2230,7 +2230,7 @@ static nsresult NSAPI nsURI_SetPath(nsIFileURL *iface, const nsACString *aPath)
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
nsACString_GetData(aPath, &patha); nsACString_GetData(aPath, &patha);
path = heap_strdupAtoW(patha); path = heap_strdupUtoW(patha);
if(!path) if(!path)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -2292,7 +2292,7 @@ static nsresult NSAPI nsURI_SchemeIs(nsIFileURL *iface, const char *scheme, cpp_
if(FAILED(hres)) if(FAILED(hres))
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
MultiByteToWideChar(CP_ACP, 0, scheme, -1, buf, sizeof(buf)/sizeof(WCHAR)); MultiByteToWideChar(CP_UTF8, 0, scheme, -1, buf, sizeof(buf)/sizeof(WCHAR));
*_retval = !strcmpW(scheme_name, buf); *_retval = !strcmpW(scheme_name, buf);
SysFreeString(scheme_name); SysFreeString(scheme_name);
return NS_OK; return NS_OK;
@ -2336,7 +2336,7 @@ static nsresult NSAPI nsURI_Resolve(nsIFileURL *iface, const nsACString *aRelati
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
nsACString_GetData(aRelativePath, &patha); nsACString_GetData(aRelativePath, &patha);
path = heap_strdupAtoW(patha); path = heap_strdupUtoW(patha);
if(!path) if(!path)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -2352,7 +2352,7 @@ static nsresult NSAPI nsURI_Resolve(nsIFileURL *iface, const nsACString *aRelati
if(FAILED(hres)) if(FAILED(hres))
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
reta = heap_strdupWtoA(ret); reta = heap_strdupWtoU(ret);
SysFreeString(ret); SysFreeString(ret);
if(!reta) if(!reta)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -2404,7 +2404,7 @@ static nsresult NSAPI nsURL_GetRef(nsIFileURL *iface, nsACString *aRef)
if(FAILED(hres)) if(FAILED(hres))
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
refa = heap_strdupWtoA(ref); refa = heap_strdupWtoU(ref);
SysFreeString(ref); SysFreeString(ref);
if(ref && !refa) if(ref && !refa)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -2427,7 +2427,7 @@ static nsresult NSAPI nsURL_SetRef(nsIFileURL *iface, const nsACString *aRef)
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
nsACString_GetData(aRef, &refa); nsACString_GetData(aRef, &refa);
ref = heap_strdupAtoW(refa); ref = heap_strdupUtoW(refa);
if(!ref) if(!ref)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@ -2563,7 +2563,7 @@ static nsresult NSAPI nsURL_SetQuery(nsIFileURL *iface, const nsACString *aQuery
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
nsACString_GetData(aQuery, &querya); nsACString_GetData(aQuery, &querya);
query = heap_strdupAtoW(querya); query = heap_strdupUtoW(querya);
if(!query) if(!query)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;