mirror of
https://github.com/microsoft/terminal.git
synced 2026-04-06 14:19:45 +00:00
Add a maximum OSC 8 URI length of 2MB following iTerm2 (#14198)
c0b2f488c1Unlike iTerm2, we're not planning on making it configurable. This commit also adds a max length of 1024 characters on the "display URI" that we pass up to XAML, so as to not inundate the UI. Fixes #14200 (cherry picked from commit07201d6cd1) Service-Card-Id: 86182617 Service-Version: 1.15
This commit is contained in:
committed by
Dustin Howett
parent
24a8463818
commit
0f6d29adaf
@@ -659,7 +659,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
auto lock = _terminal->LockForReading(); // Lock for the duration of our reads.
|
||||
if (_lastHoveredCell.has_value())
|
||||
{
|
||||
return winrt::hstring{ _terminal->GetHyperlinkAtPosition(*_lastHoveredCell) };
|
||||
auto uri{ _terminal->GetHyperlinkAtPosition(*_lastHoveredCell) };
|
||||
uri.resize(std::min<size_t>(1024u, uri.size())); // Truncate for display
|
||||
return winrt::hstring{ uri };
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -973,7 +973,7 @@ bool OutputStateMachineEngine::_ParseHyperlink(const std::wstring_view string,
|
||||
const auto midPos = string.find(';');
|
||||
if (midPos != std::wstring::npos)
|
||||
{
|
||||
uri = string.substr(midPos + 1);
|
||||
uri = string.substr(midPos + 1, MAX_URL_LENGTH);
|
||||
const auto paramStr = string.substr(0, midPos);
|
||||
const auto paramParts = Utils::SplitString(paramStr, ':');
|
||||
for (const auto& part : paramParts)
|
||||
|
||||
@@ -26,6 +26,8 @@ namespace Microsoft::Console::VirtualTerminal
|
||||
class OutputStateMachineEngine : public IStateMachineEngine
|
||||
{
|
||||
public:
|
||||
static constexpr size_t MAX_URL_LENGTH = 2 * 1048576; // 2MB, like iTerm2
|
||||
|
||||
OutputStateMachineEngine(std::unique_ptr<ITermDispatch> pDispatch);
|
||||
|
||||
bool ActionExecute(const wchar_t wch) override;
|
||||
|
||||
Reference in New Issue
Block a user