riched20: Reject RTF that is recognized as invalid.

oldstable
Alex Villacís Lasso 2008-04-24 10:07:12 -05:00 committed by Alexandre Julliard
parent d10256f309
commit 4f95cf7072
3 changed files with 3 additions and 15 deletions

View File

@ -1029,6 +1029,7 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
int from, to, to2, nUndoMode;
int nEventMask = editor->nEventMask;
ME_InStream inStream;
BOOL invalidRTF = FALSE;
TRACE("stream==%p hWnd==%p format==0x%X\n", stream, editor->hWnd, format);
editor->nEventMask = 0;
@ -1071,13 +1072,12 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
if ((!editor->bEmulateVersion10 && strncmp(inStream.buffer, "{\\rtf", 5) && strncmp(inStream.buffer, "{\\urtf", 6))
|| (editor->bEmulateVersion10 && *inStream.buffer != '{'))
{
format &= ~SF_RTF;
format |= SF_TEXT;
invalidRTF = TRUE;
}
}
}
if (!inStream.editstream->dwError)
if (!invalidRTF && !inStream.editstream->dwError)
{
if (format & SF_RTF) {
/* setup the RTF parser */

View File

@ -2415,28 +2415,20 @@ static void test_EM_STREAMIN(void)
(WPARAM)(SF_RTF), (LPARAM)&es);
result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
todo_wine {
ok (result == 0,
"EM_STREAMIN: Test 2 returned %ld, expected 0\n", result);
}
todo_wine {
ok (strlen(buffer) == 0,
"EM_STREAMIN: Test 2 set wrong text: Result: %s\n",buffer);
}
es.dwCookie = (DWORD_PTR)&streamText3;
SendMessage(hwndRichEdit, EM_STREAMIN,
(WPARAM)(SF_RTF), (LPARAM)&es);
result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
todo_wine {
ok (result == 0,
"EM_STREAMIN: Test 3 returned %ld, expected 9\n", result);
}
todo_wine {
ok (strlen(buffer) == 0,
"EM_STREAMIN: Test 3 set wrong text: Result: %s\n",buffer);
}
DestroyWindow(hwndRichEdit);
}

View File

@ -276,14 +276,10 @@ static void test_EM_STREAMIN(void)
(WPARAM)(SF_RTF), (LPARAM)&es);
result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
todo_wine {
ok (result == 0,
"EM_STREAMIN: Test 3 returned %ld, expected 0\n", result);
}
todo_wine {
ok (strlen(buffer) == 0,
"EM_STREAMIN: Test 3 set wrong text: Result: %s\n",buffer);
}
DestroyWindow(hwndRichEdit);
}