Skip to content

Commit 6b44d8c

Browse files
author
Console Service Bot
committed
Merge remote-tracking branch 'origin/main' into feature/llm
2 parents f84f6a5 + 224ac9d commit 6b44d8c

File tree

4 files changed

+124
-7
lines changed

4 files changed

+124
-7
lines changed

.github/actions/spelling/allow/apis.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ ubrk
179179
UChar
180180
UFIELD
181181
ULARGE
182+
UNCEx
182183
UOI
183184
UPDATEINIFILE
184185
urlmon

src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,16 @@ static void _resolveSingleMediaResourceInner(Model::OriginTag origin, std::wstri
587587
}
588588
}
589589

590+
if (origin == winrt::Microsoft::Terminal::Settings::Model::OriginTag::Fragment)
591+
{
592+
if (PathIsUNCEx(resourcePath.c_str(), nullptr))
593+
{
594+
// A UNC path is just another type of network path, which fragments are not allowed to specify.
595+
resource.Reject();
596+
return;
597+
}
598+
}
599+
590600
// Not a URI? Try a path.
591601
try
592602
{

src/cascadia/UnitTests_SettingsModel/MediaResourceTests.cpp

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ namespace SettingsModelUnitTests
103103
TEST_METHOD(RealResolverFilePaths);
104104
TEST_METHOD(RealResolverSpecialKeywords);
105105
TEST_METHOD(RealResolverUrlCases);
106+
TEST_METHOD(RealResolverUNCCases);
106107

107108
static constexpr std::wstring_view pingCommandline{ LR"(C:\Windows\System32\PING.EXE)" }; // Normalized by Profile (this is the casing that Windows stores on disk)
108109
static constexpr std::wstring_view overrideCommandline{ LR"(C:\Windows\System32\cscript.exe)" };
@@ -1342,5 +1343,95 @@ namespace SettingsModelUnitTests
13421343
VERIFY_ARE_NOT_EQUAL(image.Resolved(), image.Path());
13431344
}
13441345
}
1346+
1347+
void MediaResourceTests::RealResolverUNCCases()
1348+
{
1349+
WEX::TestExecution::DisableVerifyExceptions disableVerifyExceptions{};
1350+
1351+
g_mediaResolverHook = nullptr; // Use the real resolver
1352+
1353+
// For profile, we test images instead of icon because Icon has a fallback behavior.
1354+
auto settings = createSettingsWithFragments(R"({})", { Fragment{ L"fragment", fragmentBasePath1, R"(
1355+
{
1356+
"profiles": {
1357+
"list": [
1358+
{
1359+
"backgroundImage": "\\\\server",
1360+
"name": "ProfileUNCServerOnly"
1361+
},
1362+
{
1363+
"backgroundImage": "\\\\server\\share",
1364+
"name": "ProfileUNCServerShare"
1365+
},
1366+
{
1367+
"backgroundImage": "\\\\server\\share\\file",
1368+
"name": "ProfileUNCFullPath"
1369+
},
1370+
{
1371+
"backgroundImage": "\\\\?\\UNC\\server",
1372+
"name": "ProfileWin32NamespaceUNCServerOnly"
1373+
},
1374+
{
1375+
"backgroundImage": "\\\\?\\UNC\\server\\share",
1376+
"name": "ProfileWin32NamespaceUNCServerShare"
1377+
},
1378+
{
1379+
"backgroundImage": "\\\\?\\UNC\\server\\share\\file",
1380+
"name": "ProfileWin32NamespaceUNCFullPath"
1381+
},
1382+
{
1383+
"backgroundImage": "\\\\?\\C:\\Windows\\System32\\cmd.exe",
1384+
"name": "ProfileWin32NamespaceDrivePath"
1385+
},
1386+
]
1387+
}
1388+
})" } });
1389+
1390+
{
1391+
auto profile{ settings->GetProfileByName(L"ProfileUNCServerOnly") };
1392+
auto image{ profile.DefaultAppearance().BackgroundImagePath() };
1393+
VERIFY_IS_FALSE(image.Ok());
1394+
}
1395+
1396+
{
1397+
auto profile{ settings->GetProfileByName(L"ProfileUNCServerShare") };
1398+
auto image{ profile.DefaultAppearance().BackgroundImagePath() };
1399+
VERIFY_IS_FALSE(image.Ok());
1400+
}
1401+
1402+
{
1403+
auto profile{ settings->GetProfileByName(L"ProfileUNCFullPath") };
1404+
auto image{ profile.DefaultAppearance().BackgroundImagePath() };
1405+
VERIFY_IS_FALSE(image.Ok());
1406+
}
1407+
1408+
{
1409+
auto profile{ settings->GetProfileByName(L"ProfileWin32NamespaceUNCServerOnly") };
1410+
auto image{ profile.DefaultAppearance().BackgroundImagePath() };
1411+
VERIFY_IS_FALSE(image.Ok());
1412+
}
1413+
1414+
{
1415+
auto profile{ settings->GetProfileByName(L"ProfileWin32NamespaceUNCServerShare") };
1416+
auto image{ profile.DefaultAppearance().BackgroundImagePath() };
1417+
VERIFY_IS_FALSE(image.Ok());
1418+
}
1419+
1420+
{
1421+
auto profile{ settings->GetProfileByName(L"ProfileWin32NamespaceUNCFullPath") };
1422+
auto image{ profile.DefaultAppearance().BackgroundImagePath() };
1423+
VERIFY_IS_FALSE(image.Ok());
1424+
}
1425+
1426+
// The only one of these paths which is OK is the one to \\?\C:\Windows
1427+
{
1428+
auto profile{ settings->GetProfileByName(L"ProfileWin32NamespaceDrivePath") };
1429+
auto image{ profile.DefaultAppearance().BackgroundImagePath() };
1430+
VERIFY_IS_TRUE(image.Ok());
1431+
}
1432+
1433+
// We cannot test that user-originated UNC paths resolve properly because we cannot guarantee
1434+
// the existence of a network share on any test machine, be it in a lab or owned by a user.
1435+
}
13451436
#pragma endregion
13461437
}

src/terminal/parser/InputStateMachineEngine.cpp

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -391,19 +391,18 @@ bool InputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParameter
391391
//
392392
// Focus events in conpty are special, so don't flush those through either.
393393
// See GH#12799, GH#12900 for details
394-
if (_pDispatch->IsVtInputEnabled() &&
395-
id != CsiActionCodes::Win32KeyboardInput &&
396-
id != CsiActionCodes::FocusIn &&
397-
id != CsiActionCodes::FocusOut)
398-
{
399-
return false;
400-
}
394+
const auto vtInputEnabled = _pDispatch->IsVtInputEnabled();
401395

402396
switch (id)
403397
{
404398
case CsiActionCodes::MouseDown:
405399
case CsiActionCodes::MouseUp:
406400
{
401+
if (vtInputEnabled)
402+
{
403+
return false;
404+
}
405+
407406
DWORD buttonState = 0;
408407
DWORD eventFlags = 0;
409408
const auto firstParameter = parameters.at(0).value_or(0);
@@ -432,6 +431,10 @@ bool InputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParameter
432431
{
433432
return false;
434433
}
434+
if (vtInputEnabled)
435+
{
436+
return false;
437+
}
435438
[[fallthrough]];
436439
case CsiActionCodes::ArrowUp:
437440
case CsiActionCodes::ArrowDown:
@@ -443,6 +446,10 @@ bool InputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParameter
443446
case CsiActionCodes::CSI_F2:
444447
case CsiActionCodes::CSI_F4:
445448
{
449+
if (vtInputEnabled)
450+
{
451+
return false;
452+
}
446453
short vkey = 0;
447454
if (_GetCursorKeysVkey(id, vkey))
448455
{
@@ -453,6 +460,10 @@ bool InputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParameter
453460
}
454461
case CsiActionCodes::Generic:
455462
{
463+
if (vtInputEnabled)
464+
{
465+
return false;
466+
}
456467
short vkey = 0;
457468
if (_GetGenericVkey(parameters.at(0), vkey))
458469
{
@@ -462,6 +473,10 @@ bool InputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParameter
462473
return true;
463474
}
464475
case CsiActionCodes::CursorBackTab:
476+
if (vtInputEnabled)
477+
{
478+
return false;
479+
}
465480
_WriteSingleKey(VK_TAB, SHIFT_PRESSED);
466481
return true;
467482
case CsiActionCodes::FocusIn:

0 commit comments

Comments
 (0)