bug 624789 - allow for non-ASCII characters when reading plugin info strings on OS X. r=josh a=josh

This commit is contained in:
Jonathan Kew 2011-01-14 13:15:48 +00:00
Родитель 5c42411612
Коммит 4c7f28498c
2 изменённых файлов: 21 добавлений и 6 удалений

Просмотреть файл

@ -285,7 +285,7 @@ static nsresult ConvertToUTF8(nsIUnicodeDecoder *aUnicodeDecoder,
nsresult nsPluginTag::EnsureMembersAreUTF8()
{
#ifdef XP_WIN
#if defined(XP_WIN) || defined(XP_MACOSX)
return NS_OK;
#else
nsresult rv;

Просмотреть файл

@ -124,12 +124,27 @@ PRBool nsPluginsDir::IsPluginFile(nsIFile* file)
// Caller is responsible for freeing returned buffer.
static char* CFStringRefToUTF8Buffer(CFStringRef cfString)
{
int bufferLength = ::CFStringGetLength(cfString) + 1;
char* newBuffer = static_cast<char*>(NS_Alloc(bufferLength));
if (newBuffer && !::CFStringGetCString(cfString, newBuffer, bufferLength, kCFStringEncodingUTF8)) {
NS_Free(newBuffer);
newBuffer = nsnull;
const char* buffer = ::CFStringGetCStringPtr(cfString, kCFStringEncodingUTF8);
if (buffer) {
return PL_strdup(buffer);
}
int bufferLength =
::CFStringGetMaximumSizeForEncoding(::CFStringGetLength(cfString),
kCFStringEncodingUTF8) + 1;
char* newBuffer = static_cast<char*>(NS_Alloc(bufferLength));
if (!newBuffer) {
return nsnull;
}
if (!::CFStringGetCString(cfString, newBuffer, bufferLength,
kCFStringEncodingUTF8)) {
NS_Free(newBuffer);
return nsnull;
}
newBuffer = static_cast<char*>(NS_Realloc(newBuffer,
PL_strlen(newBuffer) + 1));
return newBuffer;
}