Commit 632015dc authored by Dylan Smith's avatar Dylan Smith Committed by Alexandre Julliard

richedit: Set error codes and stop parsing for some rtf syntax errors.

Checks were added for hexadecimal values that did not have valid characters, and for EOF received before the final closing brace of the rich text stream. The error values were tested on richedit versions 1, 2, 3 & 4.1, and they were all the same for these cases.
parent 461830a8
......@@ -969,11 +969,11 @@ static void ME_RTFReadHook(RTF_Info *info) {
{
ME_Style *s;
RTFFlushOutputBuffer(info);
if (info->stackTop<=1) {
info->stackTop--;
if (info->stackTop<=0) {
info->rtfClass = rtfEOF;
return;
}
info->stackTop--;
assert(info->stackTop >= 0);
if (info->styleChanged)
{
......@@ -1101,6 +1101,9 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
if (parser.lpRichEditOle)
IRichEditOle_Release(parser.lpRichEditOle);
if (!inStream.editstream->dwError && parser.stackTop > 0)
inStream.editstream->dwError = HRESULT_FROM_WIN32(ERROR_HANDLE_EOF);
/* Remove last line break, as mandated by tests. This is not affected by
CR/LF counters, since RTF streaming presents only \para tokens, which
are converted according to the standard rules: \r for 2.0, \r\n for 1.0
......
......@@ -638,14 +638,16 @@ static void _RTFGetToken2(RTF_Info *info)
{
int c2;
if ((c = GetChar (info)) != EOF && (c2 = GetChar (info)) != EOF)
if ((c = GetChar (info)) != EOF && (c2 = GetChar (info)) != EOF
&& isxdigit(c) && isxdigit(c2))
{
/* should do isxdigit check! */
info->rtfClass = rtfText;
info->rtfMajor = RTFCharToHex (c) * 16 + RTFCharToHex (c2);
return;
}
/* early eof, whoops (class is rtfUnknown) */
/* early eof, whoops */
info->rtfClass = rtfEOF;
info->stream->editstream->dwError = -14;
return;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment