Module: wine Branch: master Commit: 632015dc626f85a61165eab89c976c0fef730a9c URL: http://source.winehq.org/git/wine.git/?a=commit;h=632015dc626f85a61165eab89c...
Author: Dylan Smith dylan.ah.smith@gmail.com Date: Thu Jun 26 16:17:25 2008 -0400
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.
---
dlls/riched20/editor.c | 7 +++++-- dlls/riched20/reader.c | 8 +++++--- 2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index f7e20e0..28850f9 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -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 diff --git a/dlls/riched20/reader.c b/dlls/riched20/reader.c index 5ee9fa2..760adec 100644 --- a/dlls/riched20/reader.c +++ b/dlls/riched20/reader.c @@ -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; }