Bug 1423855 - Quit if the profile path is not valid UTF-8 on non-Windows platforms.
On non-Windows platforms Firefox is broken in various ways (unable to save
history and bookmarks, for example) if the profile path isn't valid UTF-8.
It's better to check that up front instead of being broken in mysterious
ways.
MozReview-Commit-ID: 76XxIB3cuvh
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -15,16 +15,17 @@
#include "mozilla/MemoryChecking.h"
#include "mozilla/Poison.h"
#include "mozilla/Preferences.h"
#include "mozilla/Printf.h"
#include "mozilla/ScopeExit.h"
#include "mozilla/Services.h"
#include "mozilla/Telemetry.h"
#include "mozilla/intl/LocaleService.h"
+#include "nsNativeCharsetUtils.h"
#include "nsAppRunner.h"
#include "mozilla/XREAppData.h"
#include "mozilla/Bootstrap.h"
#if defined(MOZ_UPDATER) && !defined(MOZ_WIDGET_ANDROID)
#include "nsUpdateDriver.h"
#endif
#include "ProfileReset.h"
@@ -4462,16 +4463,26 @@ XREMain::XRE_mainRun()
}
// Need to write out the fact that the profile has been removed, the new profile
// renamed, and potentially that the selected/default profile changed.
mProfileSvc->Flush();
}
}
+ if (NS_IsNativeUTF8()) {
+ nsCOMPtr<nsIFile> profileDir;
+ nsAutoCString path;
+ rv = mDirProvider.GetProfileStartupDir(getter_AddRefs(profileDir));
+ if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(profileDir->GetNativePath(path)) && !IsUTF8(path)) {
+ PR_fprintf(PR_STDERR, "Error: The profile path is not valid UTF-8. Unable to continue.\n");
+ return NS_ERROR_FAILURE;
+ }
+ }
+
// Initialize user preferences before notifying startup observers so they're
// ready in time for early consumers, such as the component loader.
mDirProvider.InitializeUserPrefs();
{
nsCOMPtr<nsIObserver> startupNotifier
(do_CreateInstance(NS_APPSTARTUPNOTIFIER_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);