Skip to content

Commit

Permalink
Bug 1752683 - Stop passing 8.3 names to NSS for SQLite db paths. r=ke…
Browse files Browse the repository at this point in the history
…eler,florian

We pass 8.3 names to NSS to avoid non-ASCII characters because NSS still
depends on the system code page (although this workaround is not effective on
East-Asian locales).

We don't have to use 8.3 names to NSS for SQLite db paths because SQLite
always use UTF-8 for file names.

Differential Revision: https://phabricator.services.mozilla.com/D137379
  • Loading branch information
vyv03354 committed Jan 31, 2022
1 parent a6b22fc commit b5ee5d9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ add_task(async function() {
);
processes[process].forEach(entry => {
entry.listedPath = entry.path;
entry.path = expandPathWithDirServiceKey(entry.path, entry.canonicalize);
entry.path = expandPathWithDirServiceKey(entry.path);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ const kSharedFontList = SpecialPowers.getBoolPref("gfx.e10s.font-list.shared");
* It's possible to have only a prefix, in thise case the directory will
* still be resolved, eg. "UAppData:"
* - use * at the begining and/or end as a wildcard
* - For Windows specific entries that require resolving the path to its
* canonical form, ie. the old DOS 8.3 format, use canonicalize: true.
* This is needed for stat calls to non-existent files.
* The folder separator is '/' even for Windows paths, where it'll be
* automatically converted to '\'.
*
Expand Down Expand Up @@ -362,26 +359,16 @@ const startupPhases = {
read: 5,
stat: AppConstants.NIGHTLY_BUILD ? 5 : 4,
},
{
// bug 1370516 - NSS should be initialized off main thread.
path: `ProfD:cert9.db`,
condition: WIN,
ignoreIfUnused: true, // if canonicalize(ProfD) == ProfD, we'll use the previous entry.
canonicalize: true,
stat: 4,
},
{
// bug 1370516 - NSS should be initialized off main thread.
path: `ProfD:cert9.db-journal`,
condition: WIN,
canonicalize: true,
stat: 3,
},
{
// bug 1370516 - NSS should be initialized off main thread.
path: `ProfD:cert9.db-wal`,
condition: WIN,
canonicalize: true,
stat: 3,
},
{
Expand All @@ -397,26 +384,16 @@ const startupPhases = {
read: 8,
stat: AppConstants.NIGHTLY_BUILD ? 5 : 4,
},
{
// bug 1370516 - NSS should be initialized off main thread.
path: `ProfD:key4.db`,
condition: WIN,
ignoreIfUnused: true, // if canonicalize(ProfD) == ProfD, we'll use the previous entry.
canonicalize: true,
stat: 4,
},
{
// bug 1370516 - NSS should be initialized off main thread.
path: `ProfD:key4.db-journal`,
condition: WIN,
canonicalize: true,
stat: 5,
},
{
// bug 1370516 - NSS should be initialized off main thread.
path: `ProfD:key4.db-wal`,
condition: WIN,
canonicalize: true,
stat: 5,
},
{
Expand Down Expand Up @@ -529,13 +506,11 @@ const startupPhases = {
{
path: `ProfD:key4.db-journal`,
condition: WIN,
canonicalize: true,
stat: 2,
},
{
path: `ProfD:key4.db-wal`,
condition: WIN,
canonicalize: true,
stat: 2,
},
{
Expand All @@ -555,7 +530,7 @@ for (let name of ["d3d11layers", "glcontext", "wmfvpxvideo"]) {
});
}

function expandPathWithDirServiceKey(path, canonicalize = false) {
function expandPathWithDirServiceKey(path) {
if (path.includes(":")) {
let [prefix, suffix] = path.split(":");
let [key, property] = prefix.split(".");
Expand All @@ -564,20 +539,16 @@ function expandPathWithDirServiceKey(path, canonicalize = false) {
dir = dir[property];
}

if (canonicalize) {
path = dir.QueryInterface(Ci.nsILocalFileWin).canonicalPath;
} else {
// Resolve symLinks.
let dirPath = dir.path;
while (dir && !dir.isSymlink()) {
dir = dir.parent;
}
if (dir) {
dirPath = dirPath.replace(dir.path, dir.target);
}

path = dirPath;
// Resolve symLinks.
let dirPath = dir.path;
while (dir && !dir.isSymlink()) {
dir = dir.parent;
}
if (dir) {
dirPath = dirPath.replace(dir.path, dir.target);
}

path = dirPath;

if (suffix) {
path += "/" + suffix;
Expand Down Expand Up @@ -736,7 +707,7 @@ add_task(async function() {
);
startupPhases[phase].forEach(entry => {
entry.listedPath = entry.path;
entry.path = expandPathWithDirServiceKey(entry.path, entry.canonicalize);
entry.path = expandPathWithDirServiceKey(entry.path);
});
}

Expand Down Expand Up @@ -836,7 +807,6 @@ add_task(async function() {
"listedPath",
"path",
"condition",
"canonicalize",
"ignoreIfUnused",
"_used",
].includes(op)
Expand Down
2 changes: 1 addition & 1 deletion security/manager/ssl/nsNSSComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1688,7 +1688,7 @@ static nsresult GetNSSProfilePath(nsAutoCString& aProfilePath) {
return NS_ERROR_FAILURE;
}
nsAutoString u16ProfilePath;
rv = profileFileWin->GetCanonicalPath(u16ProfilePath);
rv = profileFileWin->GetPath(u16ProfilePath);
CopyUTF16toUTF8(u16ProfilePath, aProfilePath);
#else
rv = profileFile->GetNativePath(aProfilePath);
Expand Down
7 changes: 0 additions & 7 deletions security/manager/ssl/tests/unit/test_nonascii_path.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ Assert.ok(
/[^\x20-\x7f]/.test(file.path),
"the profile path should contain a non-ASCII character"
);
if (mozinfo.os == "win") {
file.QueryInterface(Ci.nsILocalFileWin);
Assert.ok(
/[^\x20-\x7f]/.test(file.canonicalPath),
"the profile short path should contain a non-ASCII character"
);
}

// Restore the original value.
env.set("XPCSHELL_TEST_PROFILE_DIR", profd);
Expand Down

0 comments on commit b5ee5d9

Please sign in to comment.