From 0166df720923295ef200ce0ec69d19e25770c3f2 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Tue, 9 Oct 2018 01:46:11 -0400 Subject: [PATCH] regex filter added --- GUI/host/textthread.cc | 3 ++- GUI/host/textthread.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/GUI/host/textthread.cc b/GUI/host/textthread.cc index f1d7aab..88390e6 100644 --- a/GUI/host/textthread.cc +++ b/GUI/host/textthread.cc @@ -5,6 +5,7 @@ #include "textthread.h" #include "host.h" #include "const.h" +#include TextThread::TextThread(ThreadParam tp, DWORD status) : handle(ThreadCounter++), name(Host::GetHookName(tp.pid, tp.hook)), tp(tp), status(status) {} @@ -35,6 +36,7 @@ void TextThread::Flush() void TextThread::AddSentence(std::wstring sentence) { + sentence = std::regex_replace(sentence, std::wregex(filter), L""); // Dispatch to extensions occurs here. Don't hold mutex! Extensions might take a while! if (Output(this, sentence)) { @@ -49,7 +51,6 @@ void TextThread::AddText(const BYTE* data, int len) buffer += status & USING_UNICODE ? std::wstring((wchar_t*)data, len / 2) : StringToWideString(std::string((char*)data, len), status & USING_UTF8 ? CP_UTF8 : SHIFT_JIS); - if (Filter) Filter(buffer.data(), storage.c_str()); timestamp = GetTickCount(); } diff --git a/GUI/host/textthread.h b/GUI/host/textthread.h index 41fcf05..17dca6d 100644 --- a/GUI/host/textthread.h +++ b/GUI/host/textthread.h @@ -13,8 +13,8 @@ public: typedef std::function OutputCallback; inline static OutputCallback Output; - inline static std::function Filter = nullptr; + inline static std::wstring filter = L""; inline static int FlushDelay = 250; // flush every 250ms by default inline static int MaxBufferSize = 200; inline static int ThreadCounter = 0;