FX_DWORD CPDF_StreamContentParser::Parse(const uint8_t* pData, FX_DWORD dwSize, FX_DWORD max_cost) { if (m_Level > _FPDF_MAX_FORM_LEVEL_) { return dwSize; } FX_DWORD InitObjCount = m_pObjectList->CountObjects(); CPDF_StreamParser syntax(pData, dwSize); CPDF_StreamParserAutoClearer auto_clearer(&m_pSyntax, &syntax); m_CompatCount = 0; while (1) { FX_DWORD cost = m_pObjectList->CountObjects() - InitObjCount; if (max_cost && cost >= max_cost) { break; } switch (syntax.ParseNextElement()) { case CPDF_StreamParser::EndOfData: return m_pSyntax->GetPos(); case CPDF_StreamParser::Keyword: OnOperator((char*)syntax.GetWordBuf()); ClearAllParams(); break; case CPDF_StreamParser::Number: AddNumberParam((char*)syntax.GetWordBuf(), syntax.GetWordSize()); break; case CPDF_StreamParser::Name: AddNameParam((const FX_CHAR*)syntax.GetWordBuf() + 1, syntax.GetWordSize() - 1); break; default: AddObjectParam(syntax.GetObject()); } } return m_pSyntax->GetPos(); }
void CPDF_StreamContentParser::EndNumber() { if (m_ObjectSize == 0) { AddNumberParam((FX_LPCSTR)m_pWordBuf, m_WordSize); return; } CPDF_Number *pObj = FX_NEW CPDF_Number(CFX_ByteStringC(m_pWordBuf, m_WordSize)); if (!SetToCurObj(pObj)) { pObj->Release(); } }
FX_DWORD CPDF_StreamContentParser::Parse(FX_LPCBYTE pData, FX_DWORD dwSize, FX_DWORD max_cost) { if (m_Level > _FPDF_MAX_FORM_LEVEL_) { return dwSize; } FX_DWORD InitObjCount = m_pObjectList->CountObjects(); CPDF_StreamParser syntax(pData, dwSize); m_pSyntax = &syntax; m_CompatCount = 0; while (1) { FX_DWORD cost = m_pObjectList->CountObjects() - InitObjCount; if (max_cost && cost >= max_cost) { break; } switch (syntax.ParseNextElement()) { case CPDF_StreamParser::EndOfData: return m_pSyntax->GetPos(); case CPDF_StreamParser::Keyword: if(!OnOperator((char*)syntax.GetWordBuf()) && _PDF_HasInvalidOpChar((char*)syntax.GetWordBuf())) { m_bAbort = TRUE; } if (m_bAbort) { return m_pSyntax->GetPos(); } ClearAllParams(); break; case CPDF_StreamParser::Number: AddNumberParam((char*)syntax.GetWordBuf(), syntax.GetWordSize()); break; case CPDF_StreamParser::Name: AddNameParam((FX_LPCSTR)syntax.GetWordBuf() + 1, syntax.GetWordSize() - 1); break; default: AddObjectParam(syntax.GetObject()); } } return m_pSyntax->GetPos(); }