Don't generate WSL distributions for docker-desktop* (#4156)

These utility distributions are used by Docker for Windows' WSL2
integration. They are not intended for user consumption.

* [x] Closes #3556
* [x] CLA signed.
* [x] Tests added/passed
* [x] Requires documentation to be updated
* [x] I've discussed this with core contributors already.

There is a minimal chance that a user _has_ a distribution named `docker-desktop` or some superstring thereof, but this is taken as an acceptable level of risk.
This commit is contained in:
Dustin L. Howett (MSFT) 2020-01-09 12:26:04 -08:00 committed by msftbot[bot]
parent 988f0a6e77
commit 8a21698c35

View file

@ -13,6 +13,8 @@
#include <fcntl.h>
#include "DefaultProfileUtils.h"
static constexpr std::wstring_view DockerDistributionPrefix{ L"docker-desktop" };
using namespace ::TerminalApp;
// Legacy GUIDs:
@ -106,6 +108,14 @@ std::vector<TerminalApp::Profile> WslDistroGenerator::GenerateProfiles()
{
std::wstring distName;
std::getline(wlinestream, distName, L'\r');
if (distName.substr(0, std::min(distName.size(), DockerDistributionPrefix.size())) == DockerDistributionPrefix)
{
// Docker for Windows creates some utility distributions to handle Docker commands.
// Pursuant to GH#3556, because they are _not_ user-facing we want to hide them.
continue;
}
size_t firstChar = distName.find_first_of(L"( ");
// Some localizations don't have a space between the name and "(Default)"
// https://github.com/microsoft/terminal/issues/1168#issuecomment-500187109