From 8ca0d0a830550e08d4f2535143d9f43af9f9a565 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Sat, 24 Sep 2011 13:54:24 +0000 Subject: [PATCH] WebParser: Fixed that RegExp matching fails if data contains embedded NULLs --- Plugins/PluginWebParser/WebParser.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Plugins/PluginWebParser/WebParser.cpp b/Plugins/PluginWebParser/WebParser.cpp index ceecb767..e4c8180e 100644 --- a/Plugins/PluginWebParser/WebParser.cpp +++ b/Plugins/PluginWebParser/WebParser.cpp @@ -75,7 +75,7 @@ void ShowError(int lineNumber, WCHAR* errorMsg = NULL); unsigned __stdcall NetworkThreadProc(void* pParam); unsigned __stdcall NetworkDownloadThreadProc(void* pParam); void Log(int level, const WCHAR* string); -void ParseData(UrlData* urlData, LPCSTR parseData); +void ParseData(UrlData* urlData, LPCSTR parseData, DWORD dwSize); CRITICAL_SECTION g_CriticalSection; bool g_Initialized = false; @@ -828,7 +828,7 @@ unsigned __stdcall NetworkThreadProc(void* pParam) } } - ParseData(urlData, (LPCSTR)data); + ParseData(urlData, (LPCSTR)data, dwSize); delete [] data; } @@ -841,10 +841,8 @@ unsigned __stdcall NetworkThreadProc(void* pParam) return 0; // thread completed successfully } -void ParseData(UrlData* urlData, LPCSTR parseData) +void ParseData(UrlData* urlData, LPCSTR parseData, DWORD dwSize) { - size_t dwSize = 0; - // Parse the value from the data pcre* re; const char* error; @@ -884,8 +882,6 @@ void ParseData(UrlData* urlData, LPCSTR parseData) parseData = utf8Data.c_str(); } - dwSize = strlen(parseData); - rc = pcre_exec( re, // the compiled pattern NULL, // no extra data - we didn't study the pattern @@ -987,7 +983,7 @@ void ParseData(UrlData* urlData, LPCSTR parseData) // Change the index and parse the substring int index = (*i).second->stringIndex; (*i).second->stringIndex = (*i).second->stringIndex2; - ParseData((*i).second, szResult.c_str()); + ParseData((*i).second, szResult.c_str(), szResult.length()); (*i).second->stringIndex = index; } else