Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow certain non-filename characters in Export Text #13693

Merged
3 commits merged into from
Aug 11, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/cascadia/TerminalApp/TabManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,13 @@ namespace winrt::TerminalApp::implementation
THROW_IF_FAILED(dialog->SetDefaultExtension(L"txt"));

// Default to using the tab title as the file name
THROW_IF_FAILED(dialog->SetFileName((control.Title() + L".txt").c_str()));
auto filename = { control.Title() };
lhecker marked this conversation as resolved.
Show resolved Hide resolved
char unallowed_chars[] = "<>:\\/\"|?*";
for (unsigned int i = 0; i < strlen(unallowed_chars); ++i)
lhecker marked this conversation as resolved.
Show resolved Hide resolved
{
filename.erase(std::remove(filename.begin(), filename.end(), unallowed_chars[i]), filename.end());
lhecker marked this conversation as resolved.
Show resolved Hide resolved
}
THROW_IF_FAILED(dialog->SetFileName((filename + L".txt").c_str()));
});
}
else
Expand Down