summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser/cpdf_syntax_parser.h
AgeCommit message (Collapse)Author
2018-07-25Move CPDF_SyntaxParser init methods into ctor.Lei Zhang
- CPDF_SyntaxParser can no longer be initialized multiple times. - Make the file length and header offset const. - Make the header offset type FX_FILESIZE consistently. - Simplify for the common case where the header offset is 0. Change-Id: I7138db1fbcec3b7578b0239b92fc1154fa4dc4ce Reviewed-on: https://pdfium-review.googlesource.com/38850 Reviewed-by: Art Snake <art-snake@yandex-team.ru> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-07-25Use document size instead of file size while parsing.Artem Strygin
We should use document size instead of File size, because all offsets and sizes was read from document should take into account of header offset. Added some tests of parsing of documents with header offset. Also drop friendship of CPDF_SyntaxParser with CPDF_Parser. Change-Id: Iebec75ab2ee07fb644a6c653b4ef5c2e09af09fe Reviewed-on: https://pdfium-review.googlesource.com/35830 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-03Remove a parameter from CPDF_SyntaxParser::FindTag().Lei Zhang
The limit parameter is always set to 0. Change-Id: Idf7f44e1c5a895e05ad474932d3e9df85f435e3f Reviewed-on: https://pdfium-review.googlesource.com/36990 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-07-03Do data request for CPDF_Stream more smoothly.Artem Strygin
For DocumentLoader we should do reconnect to skip non-requested blocks on each requested offset jump. To reduce reconnections, read stream data first, then do all checks. Thereby the DocumentLoader will continue loading data without reconnections. Change-Id: I344d045e59c5de9e1a4aed0002ea122caa92f240 Reviewed-on: https://pdfium-review.googlesource.com/13450 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-06-26Simplify CPDF_Parser::RebuildCrossRef.Artem Strygin
Use CPDF_SyntaxParser to read data, instead manual cache. Simplify merging trailers logic. Change-Id: Icaa569f1082cde6dc9437a375c5c27e187fd6c79 Reviewed-on: https://pdfium-review.googlesource.com/35431 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-26Implement CPDF_ObjStream.Artem Strygin
It is allow do not store raw objects streams within CPDF_Document for reduce memory usage. Change-Id: I4377bd5119d87314e76f14255171618cf6ee533d Reviewed-on: https://pdfium-review.googlesource.com/35430 Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
2018-04-03Re-arrange so inline vectors come last in structs.Tom Sepez
This might make the memory tools more effective in finding OOBs. Change-Id: Id093bb0a88c37954c80d612ac00b5a168e75bdbf Reviewed-on: https://pdfium-review.googlesource.com/29550 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-03-08Remove unused constructordan sinclair
Unused. Removed. Change-Id: I493a98b22c343d44834d3648e4ef2fe9978f88b1 Reviewed-on: https://pdfium-review.googlesource.com/28250 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2017-10-02Remove useless code.Artem Strygin
Change-Id: I521d6e83f392820c40f6be930ff3bf160b766b52 Reviewed-on: https://pdfium-review.googlesource.com/15150 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-10-02Implement CPDF_CryptoHandler::DecryptObjectArtem Strygin
Decryption logic has been extracted from CPDF_SyntaxParser::GetObjectBody into CPDF_CryptoHandler::DecryptObject Performance comparison results: https://pdfium-review.googlesource.com/c/pdfium/+/12970 Change-Id: Iaeaed56b7f96166bbbcf6db162192d2ba9af4698 Reviewed-on: https://pdfium-review.googlesource.com/12971 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-09-28Fix infinite loop on form availability check.Artem Strygin
The problem was, that the CPDF_SyntaxParser read last block not from requested position. In this case It move down requested position to fill whole buffer. As result this additional data was not requested by DownloadHints. To fix this allow resize data buffer in CPDF_SyntaxParser, to store more small block, and always read from requsted position. Also add reading check into CPDF_Parser::LoadLinearizedMainXRefTable to prevent infinite loops. Change-Id: I14d3f4457393025dca390aa3ceaa940716463534 Reviewed-on: https://pdfium-review.googlesource.com/11891 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-09-21Rename CPDF_SyntaxParser::GetObject to GetObjectBodyArtem Strygin
Change-Id: Ia8fd1893f862391fbada396f505ac16985b59cd6 Reviewed-on: https://pdfium-review.googlesource.com/12850 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-09-21Move CFX_WeakPtr to WeakPtrDan Sinclair
This CL renames CFX_WeakPtr to WeakPtr and moves into the fxcrt namespace. Bug: pdfium:898 Change-Id: Ide50a8afeb1e987c48c8fbd103898745c9199d6a Reviewed-on: https://pdfium-review.googlesource.com/14621 Commit-Queue: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-09-21Move CFX_StringPoolTemplate to StringPoolTemplateDan Sinclair
This CL moves CFX_StringPoolTemplate to StringPoolTemplate and places in the fxcrt namespace. Bug: pdfium:898 Change-Id: I41c8f23d6ad814d65cd154092143efaa630a96d1 Reviewed-on: https://pdfium-review.googlesource.com/14619 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-21Rename CFX_RetainPtr to RetainPtrDan Sinclair
This CL renames CFX_RetainPtr to RetainPtr and places in the fxcrt namespace. Bug: pdfium:898 Change-Id: I8798a9f79cb0840d3f037e8d04937cedd742914e Reviewed-on: https://pdfium-review.googlesource.com/14616 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-18Convert string class namesRyan Harrison
Automated using git grep & sed. Replace StringC classes with StringView classes. Remove the CFX_ prefix and put string classes in fxcrt namespace. Change AsStringC() to AsStringView(). Rename tests from TEST(fxcrt, *String*Foo) to TEST(*String*, Foo). Couple of tests needed to have their names regularlized. BUG=pdfium:894 Change-Id: I7ca038685c8d803795f3ed02545124f7a224c83d Reviewed-on: https://pdfium-review.googlesource.com/14151 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-09-07Implement CPDF_SyntaxParser::PeekNextWord.Artem Strygin
Change-Id: I92c0bd417d9c5be59c36401efae89406e482756a Reviewed-on: https://pdfium-review.googlesource.com/12650 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-09-05Move Parsing of indirect object logic into CPDF_SyntaxParser.Artem Strygin
Change-Id: I5473d6db3e6fc247d52a83b34424958dc20387f4 Reviewed-on: https://pdfium-review.googlesource.com/12150 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
2017-08-31Remove fx_basic.hDan Sinclair
This CL removes the fx_basic.h header and fixes up includes as needed. Change-Id: I49af32a8327bdbcda40c50a61ffbd75d06609040 Reviewed-on: https://pdfium-review.googlesource.com/12670 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-08-28Unify CPDF_SyntaxParser::GetObjectXXX methods.Artem Strygin
Merge CPDF_SyntaxParser::GetObject and CPDF_SyntaxParser::GetObjectForStrict. Change-Id: Ic9ff51e24ee981c268239847e3cca1c6f6a6f269 Reviewed-on: https://pdfium-review.googlesource.com/10511 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-08-08Add validator into CPDF_SyntaxParser.Artem Strygin
Change-Id: I7fe8dcd8854e2f08b7b0ee53bde6c864108142ff Reviewed-on: https://pdfium-review.googlesource.com/9571 Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-08-01Add public access for read stream into CPDF_SyntaxParserArtem Strygin
Change-Id: I5deb6049db41387ac030a6ba5296ee6187120190 Reviewed-on: https://pdfium-review.googlesource.com/9470 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-05-03CPDF_SyntaxParser::SearchWord() is always backwards and for whole-wordsTom Sepez
Change-Id: Ic31d9cda5e919a754162e14e69cb63671a3fe8b9 Reviewed-on: https://pdfium-review.googlesource.com/4794 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-05-03SetPos to at most the file length to avoid overflowsNicolas Pena
This CL prevents arbitrary position setting which may cause integer overflows. In the bug in question, the PDF says the xrefs are located in a huge position. This then causes problems when calling CPDF_SyntaxParser methods. Bug: chromium:603545 Change-Id: I5f94c38f46a0217e9f12f1bf8b2f3bee3b03cb35 Reviewed-on: https://pdfium-review.googlesource.com/4813 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-04-13Refcount CPDF_CryptoHandlerchromium/3076chromium/3075chromium/3074chromium/3073chromium/3072Tom Sepez
Avoid tracking ownership via m_bLocalCryptoHandler. Also remove m_bEncryptCloned, as it is always false. Replace some methods with direct calls to underlying code. Change-Id: Ifa9d6f721c59d07e3b8e258f76832ca9f2ea0fc9 Reviewed-on: https://pdfium-review.googlesource.com/4111 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2016-12-07Refcount all the IFX_ stream classes all the time.tsepez
We can remove a lot of "bOwnsStream" logic in the process. Always pass these by const reference, in case the called method wants to hang on to the stream (one exception is where we stick a raw pointer into a void* slot in a context from another layer). Review-Url: https://codereview.chromium.org/2451493002
2016-11-22Use more unique_ptrs in CPDF_SyntaxParser and CPDF_Annotchromium/2929tsepez
Review-Url: https://codereview.chromium.org/2526543003
2016-11-16Make CPDF_Object subclass constructors intern stringstsepez
Make CDPF_Arrays intern the object they create. Allow passing nullptr as a CFX_WeakPtr shortcut as well. Review-Url: https://codereview.chromium.org/2509123002
2016-11-07Use unique_ptr return from CPDF_Parser::ParseIndirectObject()tsepez
In turn, propgate to callers. This introduces a few release() calls that will go away as more code is converted. It also removes a couple of WrapUnique calls that are no longer needed as ownership of the object flows along. Review-Url: https://codereview.chromium.org/2479303002
2016-11-03Clean up CPDF_SyntaxParser a little bitnpm
- Added a private method to read a character. - Added enum for parsing status. - Deleted unused method. Review-Url: https://codereview.chromium.org/2469833002
2016-11-02Remove FX_BOOL from coretsepez
Review-Url: https://codereview.chromium.org/2477443002
2016-10-24Rename IFX_ stream nameschromium/2900tsepez
It's been troubling for some time that an IFX_FileStream might actually be an in-memory buffer with no backing file. Review-Url: https://codereview.chromium.org/2443723002
2016-10-04Move core/fpdfapi/fpdf_parser to core/fpdfapi/parserdsinclair
BUG=pdfium:603 Review-Url: https://codereview.chromium.org/2392603004