From 087300b294b87ab2705244908ec932a5a8c98262 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 13 Dec 2014 19:53:55 +0000 Subject: fix for the url extractor git-svn-id: http://svn.miranda-ng.org/main/trunk@11377 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TabSRMM/src/utils.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'plugins/TabSRMM/src/utils.cpp') diff --git a/plugins/TabSRMM/src/utils.cpp b/plugins/TabSRMM/src/utils.cpp index 960def80c4..80bded6da8 100644 --- a/plugins/TabSRMM/src/utils.cpp +++ b/plugins/TabSRMM/src/utils.cpp @@ -959,23 +959,22 @@ bool Utils::extractResource(const HMODULE h, const UINT uID, const TCHAR *tszNam // @param hwndRich - rich edit window handle // @return wchar_t* extracted URL -const wchar_t* Utils::extractURLFromRichEdit(const ENLINK* _e, const HWND hwndRich) +TCHAR* Utils::extractURLFromRichEdit(const ENLINK* _e, const HWND hwndRich) { - TEXTRANGEW tr = {0}; - CHARRANGE sel = {0}; - - ::SendMessageW(hwndRich, EM_EXGETSEL, 0, (LPARAM)&sel); + CHARRANGE sel = {0}; + ::SendMessage(hwndRich, EM_EXGETSEL, 0, (LPARAM)&sel); if (sel.cpMin != sel.cpMax) return 0; + TEXTRANGE tr; tr.chrg = _e->chrg; - tr.lpstrText = (wchar_t *)mir_alloc(2 * (tr.chrg.cpMax - tr.chrg.cpMin + 8)); - ::SendMessageW(hwndRich, EM_GETTEXTRANGE, 0, (LPARAM)&tr); - if (wcschr(tr.lpstrText, '@') != NULL && wcschr(tr.lpstrText, ':') == NULL && wcschr(tr.lpstrText, '/') == NULL) { - ::memmove(tr.lpstrText + 7, tr.lpstrText, sizeof(wchar_t) * (tr.chrg.cpMax - tr.chrg.cpMin + 1)); - ::memcpy(tr.lpstrText, L"mailto:", 7 * sizeof(wchar_t)); + tr.lpstrText = (TCHAR*)mir_alloc(sizeof(TCHAR) * (tr.chrg.cpMax - tr.chrg.cpMin + 8)); + ::SendMessage(hwndRich, EM_GETTEXTRANGE, 0, (LPARAM)&tr); + if (_tcschr(tr.lpstrText, '@') != NULL && _tcschr(tr.lpstrText, ':') == NULL && _tcschr(tr.lpstrText, '/') == NULL) { + mir_tstrncpy(tr.lpstrText, _T("mailto:"), 7); + mir_tstrncpy(tr.lpstrText + 7, tr.lpstrText, tr.chrg.cpMax - tr.chrg.cpMin + 1); } - return(tr.lpstrText); + return tr.lpstrText; } ///////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3