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

Fix don't show title in recent files list may not work because title have special chars. #1035

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
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
12 changes: 12 additions & 0 deletions src/DSUtil/text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include <atlutil.h>
#include "text.h"
#include <memory>
#include <regex>
#include <array>

DWORD CharSetToCodePage(DWORD dwCharSet)
{
Expand Down Expand Up @@ -354,5 +356,15 @@ int LastIndexOfCString(const CString& text, const CString& pattern) {

bool IsNameSimilar(const CString& title, const CString& fileName) {
if (fileName.Find(title.Left(25)) > -1) return true;
CT2CW t(title);
std::wstring tit(t);
const std::wregex reg(LR"([^[:print:]]|[/\\:\*\?"<>\|])", std::regex_constants::ECMAScript);
if (!std::regex_search(tit, reg)) return false;
const std::array<std::wstring, 3> arr = { L"_", L"-", L"." };
for (auto& r : arr) {
std::wstring temp = std::regex_replace(tit, reg, r);
CStringW newtitle(temp.c_str());
if (fileName.Find(newtitle.Left(25)) > -1) return true;
}
return false;
}