Closed Bug 1423855 Opened 8 years ago Closed 8 years ago

Refuse to run on non-Windows platforms if the profile path is not valid UTF-8

Categories

(Toolkit :: General, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla59
Tracking Status
firefox59 --- fixed

People

(Reporter: hsivonen, Assigned: hsivonen)

References

Details

Attachments

(1 file)

Firefox is broken in various ways on non-Windows platforms is the profile path is not valid UTF-8. Let's check that it is and quit up front if it isn't instead of exhibiting mysterious brokenness.
Attachment #8935307 - Flags: review?(mh+mozilla)
Note that this assumes the new definition of NS_IsNativeUTF8() from bug 960957.
See Also: → 960957
Comment on attachment 8935307 [details] Bug 1423855 - Quit if the profile path is not valid UTF-8 on non-Windows platforms. https://reviewboard.mozilla.org/r/206206/#review212050 ::: toolkit/xre/nsAppRunner.cpp:4494 (Diff revision 1) > + if (NS_IsNativeUTF8()) { > + // mDirProvider.DoStartup(); immediately above initialized > + // NS_APP_USER_PROFILE_50_DIR availability. > + nsCOMPtr<nsIFile> profileDir; > + nsAutoCString path; > + rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, you should be able to use mDirProvider.GetUserAppDataDirectory here, and you could do that before mDirProvider.DoStartup and thus before appStartup, meaning you could also just do a simple return NS_ERROR_FAILURE. ::: toolkit/xre/nsAppRunner.cpp:4497 (Diff revision 1) > + static const char sUTF8PathMessage[] = "The profile path is not valid UTF-8. Unable to continue.\n"; > + // Ignoring return values, since there isn't much we could do on failure and there is no > + // point in trying to recover from errors. > + MOZ_UNUSED(write(STDERR_FILENO, sUTF8PathMessage, MOZ_ARRAY_LENGTH(sUTF8PathMessage) - 1)); We're using PR_fprintf everywhere in this file, you might as well use that.
Attachment #8935307 - Flags: review?(mh+mozilla)
Comment on attachment 8935307 [details] Bug 1423855 - Quit if the profile path is not valid UTF-8 on non-Windows platforms. https://reviewboard.mozilla.org/r/206206/#review212246 ::: toolkit/xre/nsAppRunner.cpp:4494 (Diff revision 1) > + if (NS_IsNativeUTF8()) { > + // mDirProvider.DoStartup(); immediately above initialized > + // NS_APP_USER_PROFILE_50_DIR availability. > + nsCOMPtr<nsIFile> profileDir; > + nsAutoCString path; > + rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, Looks like `GetUserAppDataDirectory()` isn't the right directory. `GetProfileStartupDir()` looks like the most correct one before `DoStartup` given that `GetProfileDir()` is explicitly wrong before startup. It's unclear to me under what circumstances `GetProfileStartupDir()` and `GetProfileDir()` can d iffer and if they can only differ in embedding scenarios.
Comment on attachment 8935307 [details] Bug 1423855 - Quit if the profile path is not valid UTF-8 on non-Windows platforms. https://reviewboard.mozilla.org/r/206206/#review212050 > We're using PR_fprintf everywhere in this file, you might as well use that. Used PR_fprintf. Now after Firefox exits, I get an error that looks like it comes from python complaining about a broken pipe, but I have no clue how python would be involved.
Comment on attachment 8935307 [details] Bug 1423855 - Quit if the profile path is not valid UTF-8 on non-Windows platforms. https://reviewboard.mozilla.org/r/206206/#review212050 > you should be able to use mDirProvider.GetUserAppDataDirectory here, and you could do that before mDirProvider.DoStartup and thus before appStartup, meaning you could also just do a simple return NS_ERROR_FAILURE. Moved and used `GetProfileStartupDir()`.
Attachment #8935307 - Flags: review?(mh+mozilla)
Attachment #8935307 - Flags: review?(mh+mozilla)
Comment on attachment 8935307 [details] Bug 1423855 - Quit if the profile path is not valid UTF-8 on non-Windows platforms. https://reviewboard.mozilla.org/r/206206/#review212942
Attachment #8935307 - Flags: review?(mh+mozilla) → review+
Pushed by hsivonen@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/1ee8a8833d65 Quit if the profile path is not valid UTF-8 on non-Windows platforms. r=glandium
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla59
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: