From 0c6faf26f0ae84c2dc0daa683df5cff8ae91511c Mon Sep 17 00:00:00 2001 From: "rayw%netscape.com" Date: Mon, 15 May 2000 17:26:18 +0000 Subject: [PATCH] The remaining fix for international characters in component names. git-svn-id: svn://10.0.0.236/trunk@69804 18797224-902f-48f8-a5cc-f745e15eee43 --- .../xpconnect/loader/mozJSComponentLoader.cpp | 58 +++++++++++++++++-- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/mozilla/js/src/xpconnect/loader/mozJSComponentLoader.cpp b/mozilla/js/src/xpconnect/loader/mozJSComponentLoader.cpp index ceafdb5ae4f..3c52c50480a 100644 --- a/mozilla/js/src/xpconnect/loader/mozJSComponentLoader.cpp +++ b/mozilla/js/src/xpconnect/loader/mozJSComponentLoader.cpp @@ -412,13 +412,26 @@ nsresult mozJSComponentLoader::SetRegistryInfo(const char *registryLocation, nsIFile *component) { + nsresult rv; if (!mRegistry.get()) return NS_OK; // silent failure - nsresult rv; + PRUint32 length = strlen(registryLocation); + char* eRegistryLocation; + rv = mRegistry->EscapeKey((PRUint8*)registryLocation, 1, &length, (PRUint8**)&eRegistryLocation); + if (rv != NS_OK) + { + return rv; + } + if (eRegistryLocation == nsnull) // No escaping required + eRegistryLocation = (char*)registryLocation; + + nsRegistryKey key; - rv = mRegistry->AddSubtreeRaw(mXPCOMKey, registryLocation, &key); + rv = mRegistry->AddSubtreeRaw(mXPCOMKey, eRegistryLocation, &key); + if (registryLocation != eRegistryLocation) + nsAllocator::Free(eRegistryLocation); if (NS_FAILED(rv)) return rv; @@ -431,6 +444,8 @@ mozJSComponentLoader::SetRegistryInfo(const char *registryLocation, PRInt64 fileSize; if (NS_FAILED(rv = component->GetFileSize(&fileSize)) || NS_FAILED(rv = mRegistry->SetLongLong(key, fileSizeValueName, &fileSize))) + if (registryLocation != eRegistryLocation) + nsAllocator::Free(eRegistryLocation); return rv; #ifdef DEBUG_shaver_off @@ -447,20 +462,53 @@ mozJSComponentLoader::RemoveRegistryInfo(const char *registryLocation) if (!mRegistry.get()) return NS_OK; // silent failure - return mRegistry->RemoveSubtree(mXPCOMKey, registryLocation); + nsresult rv; + if (!mRegistry.get()) + return NS_OK; // silent failure + + PRUint32 length = strlen(registryLocation); + char* eRegistryLocation; + rv = mRegistry->EscapeKey((PRUint8*)registryLocation, 1, &length, (PRUint8**)&eRegistryLocation); + if (rv != NS_OK) + { + return rv; + } + if (eRegistryLocation == nsnull) // No escaping required + eRegistryLocation = (char*)registryLocation; + + + rv = mRegistry->RemoveSubtree(mXPCOMKey, eRegistryLocation); + + if (registryLocation != eRegistryLocation) + nsAllocator::Free(eRegistryLocation); + + return rv; } PRBool mozJSComponentLoader::HasChanged(const char *registryLocation, nsIFile *component) { - /* if we don't have a registry handle, force registration of component */ if (!mRegistry) return PR_TRUE; + nsresult rv; + PRUint32 length = strlen(registryLocation); + char* eRegistryLocation; + rv = mRegistry->EscapeKey((PRUint8*)registryLocation, 1, &length, (PRUint8**)&eRegistryLocation); + if (rv != NS_OK) + { + return rv; + } + if (eRegistryLocation == nsnull) // No escaping required + eRegistryLocation = (char*)registryLocation; + nsRegistryKey key; - if (NS_FAILED(mRegistry->GetSubtreeRaw(mXPCOMKey, registryLocation, &key))) + int r = NS_FAILED(mRegistry->GetSubtreeRaw(mXPCOMKey, eRegistryLocation, &key)); + if (registryLocation != eRegistryLocation) + nsAllocator::Free(eRegistryLocation); + if (r) return PR_TRUE; /* check modification date */