From 8ef4da8da6cd9621f79d45a8ecaa59942102d252 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Mon, 16 Oct 2006 14:42:04 +0000 Subject: - Don't let most characters below 0x0020 through. Old RTF's seem to have these for strange reasons. --- src/rtfparser.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/rtfparser.cpp b/src/rtfparser.cpp index 7e70fe5..6ba9abe 100644 --- a/src/rtfparser.cpp +++ b/src/rtfparser.cpp @@ -45,11 +45,11 @@ const wchar_t kAnsiToUnicode[] = { - /* Invalid, but used for wierd things in RTF anyway :( */ - 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, - 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F, - 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, - 0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F, + /* Moltly invalid, but used for wierd things in RTF anyway :( */ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0009, 0x000A, 0x0000, 0x0000, 0x000D, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* Low 7 bit, same */ 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, @@ -316,9 +316,15 @@ bool RtfParser::parseHexChar(int num, bool ansi) ASSERT((sizeof(kAnsiToUnicode) / sizeof(kAnsiToUnicode[0])) == 256); if(val < 0 || val >= 256) + { m_parseErrors.append("invalid ansi char: " + data + "\n"); + } else - sendData(kAnsiToUnicode[val]); + { + wchar_t ch = kAnsiToUnicode[val]; + if(ch) + sendData(ch); + } } else { -- cgit v1.2.3