From 58dfae4c2119cad8a21cdad1384d8fb69001c5ff Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Mon, 27 Apr 2020 12:08:08 -0500 Subject: [PATCH 1/4] Remove the title tag from the generated HTML since that seems to confuse web apps --- src/cascadia/TerminalControl/TermControl.cpp | 5 ++++- src/interactivity/win32/Clipboard.cpp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index b3ff614757b..fa0c345d32f 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -2054,11 +2054,14 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation } // convert text to HTML format + // GH#5347 - Don't provide a title for the generated HTML, as many + // web applications will paste the title first, followed by the HTML + // content, which is unexpected. const auto htmlData = TextBuffer::GenHTML(bufferData, _actualFont.GetUnscaledSize().Y, _actualFont.GetFaceName(), _settings.DefaultBackground(), - "Windows Terminal"); + ""); // convert to RTF format const auto rtfData = TextBuffer::GenRTF(bufferData, diff --git a/src/interactivity/win32/Clipboard.cpp b/src/interactivity/win32/Clipboard.cpp index f6620da7200..388a9f23c2c 100644 --- a/src/interactivity/win32/Clipboard.cpp +++ b/src/interactivity/win32/Clipboard.cpp @@ -277,7 +277,10 @@ void Clipboard::CopyTextToSystemClipboard(const TextBuffer::TextAndColor& rows, int const iFontHeightPoints = fontData.GetUnscaledSize().Y * 72 / ServiceLocator::LocateGlobals().dpi; const COLORREF bgColor = ServiceLocator::LocateGlobals().getConsoleInformation().GetDefaultBackground(); - std::string HTMLToPlaceOnClip = TextBuffer::GenHTML(rows, iFontHeightPoints, fontData.GetFaceName(), bgColor, "Windows Console Host"); + // GH#5347 - Don't provide a title for the generated HTML, as many + // web applications will paste the title first, followed by the HTML + // content, which is unexpected. + std::string HTMLToPlaceOnClip = TextBuffer::GenHTML(rows, iFontHeightPoints, fontData.GetFaceName(), bgColor, ""); CopyToSystemClipboard(HTMLToPlaceOnClip, L"HTML Format"); std::string RTFToPlaceOnClip = TextBuffer::GenRTF(rows, iFontHeightPoints, fontData.GetFaceName(), bgColor); From 8e9e2bd445affab00269ca9fec5db77cc762c30f Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Tue, 28 Apr 2020 09:52:32 -0500 Subject: [PATCH 2/4] Why even have a tag at all --- src/buffer/out/textBuffer.cpp | 8 +++++--- src/buffer/out/textBuffer.hpp | 3 +-- src/interactivity/win32/Clipboard.cpp | 5 +---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/buffer/out/textBuffer.cpp b/src/buffer/out/textBuffer.cpp index 1fbf1bbea1d..705c8d97777 100644 --- a/src/buffer/out/textBuffer.cpp +++ b/src/buffer/out/textBuffer.cpp @@ -1581,10 +1581,12 @@ const TextBuffer::TextAndColor TextBuffer::GetText(const bool includeCRLF, // - backgroundColor - default background color for characters, also used in padding // - fontHeightPoints - the unscaled font height // - fontFaceName - the name of the font used -// - htmlTitle - value used in title tag of html header. Used to name the application // Return Value: // - string containing the generated HTML -std::string TextBuffer::GenHTML(const TextAndColor& rows, const int fontHeightPoints, const std::wstring_view fontFaceName, const COLORREF backgroundColor, const std::string& htmlTitle) +std::string TextBuffer::GenHTML(const TextAndColor& rows, + const int fontHeightPoints, + const std::wstring_view fontFaceName, + const COLORREF backgroundColor) { try { @@ -1594,7 +1596,7 @@ std::string TextBuffer::GenHTML(const TextAndColor& rows, const int fontHeightPo // HTML boiler plate required for CF_HTML // as part of the HTML Clipboard format const std::string htmlHeader = - "<!DOCTYPE><HTML><HEAD><TITLE>" + htmlTitle + ""; + ""; htmlBuilder << htmlHeader; htmlBuilder << ""; diff --git a/src/buffer/out/textBuffer.hpp b/src/buffer/out/textBuffer.hpp index 351444820ba..4b409e7b95f 100644 --- a/src/buffer/out/textBuffer.hpp +++ b/src/buffer/out/textBuffer.hpp @@ -158,8 +158,7 @@ class TextBuffer final static std::string GenHTML(const TextAndColor& rows, const int fontHeightPoints, const std::wstring_view fontFaceName, - const COLORREF backgroundColor, - const std::string& htmlTitle); + const COLORREF backgroundColor); static std::string GenRTF(const TextAndColor& rows, const int fontHeightPoints, diff --git a/src/interactivity/win32/Clipboard.cpp b/src/interactivity/win32/Clipboard.cpp index 388a9f23c2c..6103d573535 100644 --- a/src/interactivity/win32/Clipboard.cpp +++ b/src/interactivity/win32/Clipboard.cpp @@ -277,10 +277,7 @@ void Clipboard::CopyTextToSystemClipboard(const TextBuffer::TextAndColor& rows, int const iFontHeightPoints = fontData.GetUnscaledSize().Y * 72 / ServiceLocator::LocateGlobals().dpi; const COLORREF bgColor = ServiceLocator::LocateGlobals().getConsoleInformation().GetDefaultBackground(); - // GH#5347 - Don't provide a title for the generated HTML, as many - // web applications will paste the title first, followed by the HTML - // content, which is unexpected. - std::string HTMLToPlaceOnClip = TextBuffer::GenHTML(rows, iFontHeightPoints, fontData.GetFaceName(), bgColor, ""); + std::string HTMLToPlaceOnClip = TextBuffer::GenHTML(rows, iFontHeightPoints, fontData.GetFaceName(), bgColor); CopyToSystemClipboard(HTMLToPlaceOnClip, L"HTML Format"); std::string RTFToPlaceOnClip = TextBuffer::GenRTF(rows, iFontHeightPoints, fontData.GetFaceName(), bgColor); From 78629e454668599148f120468d598225e5173158 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Wed, 29 Apr 2020 09:22:28 -0500 Subject: [PATCH 3/4] whoops --- src/cascadia/PublicTerminalCore/HwndTerminal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cascadia/PublicTerminalCore/HwndTerminal.cpp b/src/cascadia/PublicTerminalCore/HwndTerminal.cpp index 55b4d1066bf..79bebbe1705 100644 --- a/src/cascadia/PublicTerminalCore/HwndTerminal.cpp +++ b/src/cascadia/PublicTerminalCore/HwndTerminal.cpp @@ -727,7 +727,7 @@ HRESULT HwndTerminal::_CopyTextToSystemClipboard(const TextBuffer::TextAndColor& int const iFontHeightPoints = fontData.GetUnscaledSize().Y; // this renderer uses points already const COLORREF bgColor = _terminal->GetBackgroundColor(_terminal->GetDefaultBrushColors()); - std::string HTMLToPlaceOnClip = TextBuffer::GenHTML(rows, iFontHeightPoints, fontData.GetFaceName(), bgColor, "Hwnd Console Host"); + std::string HTMLToPlaceOnClip = TextBuffer::GenHTML(rows, iFontHeightPoints, fontData.GetFaceName(), bgColor); _CopyToSystemClipboard(HTMLToPlaceOnClip, L"HTML Format"); std::string RTFToPlaceOnClip = TextBuffer::GenRTF(rows, iFontHeightPoints, fontData.GetFaceName(), bgColor); From b3a8bb2e24bbdeae180bfb497b3019f01fbf848e Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Wed, 29 Apr 2020 10:02:42 -0500 Subject: [PATCH 4/4] what? I swear I saved this file... --- src/cascadia/TerminalControl/TermControl.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cascadia/TerminalControl/TermControl.cpp b/src/cascadia/TerminalControl/TermControl.cpp index fa0c345d32f..44466e62c35 100644 --- a/src/cascadia/TerminalControl/TermControl.cpp +++ b/src/cascadia/TerminalControl/TermControl.cpp @@ -2060,8 +2060,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation const auto htmlData = TextBuffer::GenHTML(bufferData, _actualFont.GetUnscaledSize().Y, _actualFont.GetFaceName(), - _settings.DefaultBackground(), - ""); + _settings.DefaultBackground()); // convert to RTF format const auto rtfData = TextBuffer::GenRTF(bufferData,