| Index: core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
|
| diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
|
| index e5e68c2f5c37fb32dfbc3a4dd3be96aefc658b52..bbfd4cc680b249ced935ac2e2017b72acf4fd2e1 100644
|
| --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
|
| +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
|
| @@ -5,15 +5,41 @@
|
| // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
|
|
|
| #include "../../../include/fpdfapi/fpdf_parser.h"
|
| -extern const FX_LPCSTR _PDF_CharType =
|
| - "WRRRRRRRRWWRWWRRRRRRRRRRRRRRRRRR"
|
| - "WRRRRDRRDDRNRNNDNNNNNNNNNNRRDRDR"
|
| - "RRRRRRRRRRRRRRRRRRRRRRRRRRRDRDRR"
|
| - "RRRRRRRRRRRRRRRRRRRRRRRRRRRDRDRR"
|
| - "WRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR"
|
| - "RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR"
|
| - "RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR"
|
| - "RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRW";
|
| +const char PDF_CharType[256] = {
|
| + //NUL SOH STX ETX EOT ENQ ACK BEL BS HT LF VT FF CR SO SI
|
| + 'W', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'W', 'W', 'R', 'W', 'W', 'R', 'R',
|
| +
|
| + //DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US
|
| + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R',
|
| +
|
| + //SP ! " # $ % & ยด ( ) * + , - . /
|
| + 'W', 'R', 'R', 'R', 'R', 'D', 'R', 'R', 'D', 'D', 'R', 'N', 'R', 'N', 'N', 'D',
|
| +
|
| + // 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
|
| + 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'R', 'R', 'D', 'R', 'D', 'R',
|
| +
|
| + // @ A B C D E F G H I J K L M N O
|
| + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R',
|
| +
|
| + // P Q R S T U V W X Y Z [ \ ] ^ _
|
| + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'D', 'R', 'D', 'R', 'R',
|
| +
|
| + // ` a b c d e f g h i j k l m n o
|
| + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R',
|
| +
|
| + // p q r s t u v w x y z { | } ~ DEL
|
| + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'D', 'R', 'D', 'R', 'R',
|
| +
|
| + 'W', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R',
|
| + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R',
|
| + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R',
|
| + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R',
|
| + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R',
|
| + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R',
|
| + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R',
|
| + 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'W'
|
| +};
|
| +
|
| #ifndef MAX_PATH
|
| #define MAX_PATH 4096
|
| #endif
|
| @@ -41,13 +67,13 @@ void CPDF_SimpleParser::ParseWord(FX_LPCBYTE& pStart, FX_DWORD& dwSize, int& typ
|
| return;
|
| }
|
| ch = m_pData[m_dwCurPos++];
|
| - chartype = _PDF_CharType[ch];
|
| + chartype = PDF_CharType[ch];
|
| while (chartype == 'W') {
|
| if (m_dwSize <= m_dwCurPos) {
|
| return;
|
| }
|
| ch = m_pData[m_dwCurPos++];
|
| - chartype = _PDF_CharType[ch];
|
| + chartype = PDF_CharType[ch];
|
| }
|
| if (ch != '%') {
|
| break;
|
| @@ -61,7 +87,7 @@ void CPDF_SimpleParser::ParseWord(FX_LPCBYTE& pStart, FX_DWORD& dwSize, int& typ
|
| break;
|
| }
|
| }
|
| - chartype = _PDF_CharType[ch];
|
| + chartype = PDF_CharType[ch];
|
| }
|
| FX_DWORD start_pos = m_dwCurPos - 1;
|
| pStart = m_pData + start_pos;
|
| @@ -72,7 +98,7 @@ void CPDF_SimpleParser::ParseWord(FX_LPCBYTE& pStart, FX_DWORD& dwSize, int& typ
|
| return;
|
| }
|
| ch = m_pData[m_dwCurPos++];
|
| - chartype = _PDF_CharType[ch];
|
| + chartype = PDF_CharType[ch];
|
| if (chartype != 'R' && chartype != 'N') {
|
| m_dwCurPos --;
|
| dwSize = m_dwCurPos - start_pos;
|
| @@ -117,7 +143,7 @@ void CPDF_SimpleParser::ParseWord(FX_LPCBYTE& pStart, FX_DWORD& dwSize, int& typ
|
| return;
|
| }
|
| ch = m_pData[m_dwCurPos++];
|
| - chartype = _PDF_CharType[ch];
|
| + chartype = PDF_CharType[ch];
|
| if (chartype == 'D' || chartype == 'W') {
|
| m_dwCurPos --;
|
| break;
|
| @@ -297,8 +323,8 @@ CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig)
|
| int i;
|
| for (i = 0; i < src_len; i ++) {
|
| FX_BYTE ch = src_buf[i];
|
| - if (ch >= 0x80 || _PDF_CharType[ch] == 'W' || ch == '#' ||
|
| - _PDF_CharType[ch] == 'D') {
|
| + if (ch >= 0x80 || PDF_CharType[ch] == 'W' || ch == '#' ||
|
| + PDF_CharType[ch] == 'D') {
|
| dest_len += 3;
|
| } else {
|
| dest_len ++;
|
| @@ -312,8 +338,8 @@ CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig)
|
| dest_len = 0;
|
| for (i = 0; i < src_len; i ++) {
|
| FX_BYTE ch = src_buf[i];
|
| - if (ch >= 0x80 || _PDF_CharType[ch] == 'W' || ch == '#' ||
|
| - _PDF_CharType[ch] == 'D') {
|
| + if (ch >= 0x80 || PDF_CharType[ch] == 'W' || ch == '#' ||
|
| + PDF_CharType[ch] == 'D') {
|
| dest_buf[dest_len++] = '#';
|
| dest_buf[dest_len++] = "0123456789ABCDEF"[ch / 16];
|
| dest_buf[dest_len++] = "0123456789ABCDEF"[ch % 16];
|
|
|