Trying to create a profile with a space at the end shows an XPCOM Error
Categories
(Firefox :: General, defect)
Tracking
()
People
(Reporter: mkaply, Unassigned)
Details
Comment 1•8 years ago
|
||
| Reporter | ||
Updated•8 years ago
|
Updated•3 years ago
|
| Reporter | ||
Comment 2•5 months ago
|
||
Still reproduces on current trunk, though the underlying XPCOM error has shifted from NS_ERROR_FILE_ALREADY_EXISTS (original report) to NS_ERROR_FILE_NOT_FOUND. The root cause is unchanged: on Windows, NTFS silently strips trailing spaces (and dots) from directory names at create time, so the salted profile directory ends up on disk without the trailing whitespace while the wizard's bookkeeping still references the original name. Whichever subsequent step looks for the name-as-typed throws, and the raw exception text is shown to the user via Services.prompt.alert in onFinish.
The cleanest fix is to reject the invalid name at validation time so it never reaches createProfile. No new strings required — the existing invalidChar string can be reused with the offending whitespace character as the format argument, which gives a sensible message (The character " " is not allowed in profile names. Please choose a different name.) and disables the Finish button until the user corrects it.
Patch against toolkit/profile/content/createProfileWizard.js:
@@ -207,11 +207,23 @@ function updateProfileName(aNewName) {
// Checks whether the given string is a valid profile name.
// Returns an error message describing the error in the name or "" when it's valid.
function checkProfileName(profileNameToCheck) {
// Check for emtpy profile name.
if (!/\S/.test(profileNameToCheck)) {
return gProfileManagerBundle.getString("profileNameEmpty");
}
+ // Reject leading/trailing whitespace. Windows silently strips trailing
+ // spaces (and dots) from directory names, which desyncs the wizard's
+ // bookkeeping from what's actually on disk and surfaces later as a raw
+ // XPCOM error to the user (bug 876681).
+ let trimmed = profileNameToCheck.trim();
+ if (trimmed !== profileNameToCheck) {
+ let badChar = profileNameToCheck.startsWith(trimmed)
+ ? profileNameToCheck[profileNameToCheck.length - 1]
+ : profileNameToCheck[0];
+ return gProfileManagerBundle.getFormattedString("invalidChar", [badChar]);
+ }
+
// Check whether all characters in the profile name are allowed.
if (/([\\*:?<>|\/\"])/.test(profileNameToCheck)) {
return gProfileManagerBundle.getFormattedString("invalidChar", [RegExp.$1]);
}
Untaken — happy to hand off, or revisit when I have a cycle.
Description
•