Verified Commit 3e16e633 authored by David Parks's avatar David Parks Committed by ma1
Browse files

Bug 2058013 - Only resolve non-filesystem picker results as shell libraries a=RyanVM DONTBUILD

A genuine shell library is a virtual item with no filesystem path.  A
.library-ms file is an ordinary file whose XML can name any local directory.

filedialog::GetFolderResults was passing whatever IFileDialog::GetResult
returned to IShellLibrary::LoadLibraryFromItem and, on success, replacing it
with the library's embedded default save folder.

Gating the resolution on the item being affirmatively not a filesystem object
keeps real libraries selectable and resolving as before, while a .library-ms
file "resolves" to itself -- the .library-ms file, not its target.

Original Revision: https://phabricator.services.mozilla.com/D318246

Differential Revision: https://phabricator.services.mozilla.com/D319957
parent c829ecff
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -233,7 +233,12 @@ mozilla::Result<nsString, Error> GetFolderResults(::IFileDialog* dialog) {
  }

  // If the user chose a Win7 Library, resolve to the library's
  // default save folder.
  // default save folder. Only do this for items which are known not to be
  // filesystem objects, like the user's Documents library (but not .library-ms
  // files).
  SFGAOF attrs = 0;
  if (SUCCEEDED(item->GetAttributes(SFGAO_FILESYSTEM, &attrs)) &&
      !(attrs & SFGAO_FILESYSTEM)) {
    RefPtr<IShellLibrary> shellLib;
    RefPtr<IShellItem> folderPath;
    MOZ_ENSURE_HRESULT_OK(
@@ -246,6 +251,7 @@ mozilla::Result<nsString, Error> GetFolderResults(::IFileDialog* dialog) {
                                                 getter_AddRefs(folderPath)))) {
      item.swap(folderPath);
    }
  }

  // get the folder's file system path
  nsAutoString str;