Bug 1541804: Make profile refresh for non-ascii named profiles work correctly. r=Gijs

This fixes two bugs. The first is that when the firefox profile migrator doesn't
know which profile to migrate it attempts to fall back to another profile. I
think this was intended to be the default but in bug 1322797 I ended up making
it the current profile, which is the profile we're restoring into now. I think
at this stage the profile directory doesn't even exist so things go wrong.
Changing to use the actual default works but....

When the profile migrator UI doesn't know what profile to migrate from it uses
the default profile. So if the profile you're actually trying to restore is not
the default we'll effectively throw its data into the archive and replace it
with data from the default profile. I'm inclined to say that if the migrator
does not know what profile to migrate from it should error at that point for
safety.

Why would the profile migrator not know what profile to migrate from? Because of
a long-standing text encoding problem. In C++ profile names are encoded in UTF8.
But we try to pass them to JS through an IDL parameter of type ACString. This
does no UTF8 decoding and so JS recieves an incorrect name if the name includes
non-ascii characters and so can't find the profile.

This patch fixes the IDL parameter to AUTF8String which does the decoding
correctly and so JS gets the name correctly.

We should probably think about whether just passing the nsIToolkitProfile object
to the migrator is a better choice here.

Differential Revision: https://phabricator.services.mozilla.com/D26250

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dave Townsend 2019-04-04 21:53:01 +00:00
parent 84eaf99704
commit 00de7dca50
2 changed files with 2 additions and 2 deletions

View File

@ -71,7 +71,7 @@ FirefoxProfileMigrator.prototype.getResources = function(aProfile) {
let sourceProfileDir = aProfile ? this._getAllProfiles().get(aProfile.id) :
Cc["@mozilla.org/toolkit/profile-service;1"]
.getService(Ci.nsIToolkitProfileService)
.currentProfile.rootDir;
.defaultProfile.rootDir;
if (!sourceProfileDir || !sourceProfileDir.exists() ||
!sourceProfileDir.isReadable())
return null;

View File

@ -61,7 +61,7 @@ interface nsIProfileMigrator : nsISupports
* @note The startup code ignores COM exceptions thrown from this method.
*/
void migrate(in nsIProfileStartup aStartup, in ACString aKey,
[optional] in ACString aProfileName);
[optional] in AUTF8String aProfileName);
};
%{C++