summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser/cpdf_syntax_parser.cpp
AgeCommit message (Collapse)Author
2018-06-27Add fxcrt::AutoRestorer<T>::AbandonRestoration().chromium/3475Tom Sepez
Kinda like reaching a commit point, makes going forward more useful. Change-Id: I7695b6e627d4cd8ed2bccb667d0cabd7f42c7b1c Reviewed-on: https://pdfium-review.googlesource.com/35970 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@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-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-28Remove ByteString PDF_NameDecodeDan Sinclair
This CL removes the ByteString version of PDF_NameDecode and forces the callers to use the ByteStringView variant. Change-Id: I5a955d8e909e2045ee45843af54b23e98abe00ed Reviewed-on: https://pdfium-review.googlesource.com/29350 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@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-12-01Get rid of else after break/continue/return.chromium/3284chromium/3283Lei Zhang
Change-Id: I3efc57cd7325d16e3ca8ebdeeaec06012b2c56e3 Reviewed-on: https://pdfium-review.googlesource.com/20110 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-11-02Remove some C-style const char* casts.Lei Zhang
Change-Id: I4785dd277b9da072ee3c55e2aaeb688bbf02852e Reviewed-on: https://pdfium-review.googlesource.com/17391 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-10-05Remove CPDF_Object friendsDan Sinclair
This CL removes the friends from CPDF_Object and adds accessors as needed. The m_GenNum was moved to a private member as none of the overriding classes needed access. Change-Id: If23a1a6752dea31eb80669a36694973f3c581123 Reviewed-on: https://pdfium-review.googlesource.com/15470 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@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-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-21Move CFX_AutoRestorer to fxcrt::AutoRestorerDan Sinclair
This CL renames CFX_AutoRestorer to just AutoRestorer and places in the fxcrt namespace. Bug: pdfium:898 Change-Id: Id9f36df94e95f3b2a55054bc198ca1bfd249ee3d Reviewed-on: https://pdfium-review.googlesource.com/14450 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@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-12Don't attempt to decrypt AES streams that are too shortchromium/3214Ryan Harrison
When reading a stream, if it is encrypted using an AES cipher it must be atleast 16 bytes long aka 128 bits, other wise it is malformed. BUG=chromium:763585 Change-Id: Ied7c36978f1eb24aeda93a184527b6d6a191e5c3 Reviewed-on: https://pdfium-review.googlesource.com/13751 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-07Simplify CPDF_SyntaxParser::GetNextWordInternal.Artem Strygin
Use CPDF_SyntaxParser::ToNextWord to move position on word start. Change-Id: I6b63efc9027b2a4eb4749561bf8ce2b95527d03b Reviewed-on: https://pdfium-review.googlesource.com/12830 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-09-05Remove redundant code.Artem Strygin
Do not check recursive parsing of same object in CPDF_SyntaxParser, because this problem is solved in CPDF_IndirectObjectHolder. (See https://pdfium-review.googlesource.com/c/pdfium/+/12590) Change-Id: I7829e06ae5eb06e85a0c8cfe22c1c428b55bb692 Reviewed-on: https://pdfium-review.googlesource.com/12610 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-30Move CFX_BinaryBuf out of fx_basicDan Sinclair
This CL splits the CFX_BinaryBuf out of fx_basic into its own files. The various includes have been updated. Change-Id: I0fa616eeb4df6dd229c02dc3a0597b3dced59425 Reviewed-on: https://pdfium-review.googlesource.com/12412 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-08-30Split auto restorer from fx_basicDan Sinclair
This CL moves CFX_AutoRestorer into its own file, separate from fx_basic.h. Change-Id: I415cb9207416bd4744b8ac8e2d7466852db53f0a Reviewed-on: https://pdfium-review.googlesource.com/12390 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-07-07core: fix -Wshadow warningschromium/3153Miklos Vajna
Found with this patch: diff --git a/BUILD.gn b/BUILD.gn index 83bad1b13..444685f04 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -89,6 +89,8 @@ config("pdfium_core_config") { "/wd4324", "/wd4577", ] + } else { + cflags += [ "-Wshadow" ] } } But renaming the conflicting names is tricky, so done with clang-rename. Change-Id: Ie959b86e9e82b11b211761b0c73e439e51044de7 Reviewed-on: https://pdfium-review.googlesource.com/7410 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-06-13Allow zero length streams when parsing.chromium/3130Dan Sinclair
It's possible to create a stream of length 0 in a PDF document. Currently the code will early exit and return a nullptr. This causes issues when you want to print the given PDF as the FPDF_ImportPages code ends up only generating up to the zero length object. This CL allows creating streams with length 0 and updates the PDF saving code to output a blank stream. Bug: chromium:732380 Change-Id: I44182ba4aaac7c51284b002ba01bbc34b6bcf9e0 Reviewed-on: https://pdfium-review.googlesource.com/6490 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-06-13Converting CFX_ByteTextBuf to ostringstream in cpdf_syntax_parser.cpp.Henrique Nakashima
Bug: pdfium:731 Change-Id: I6d1f59318cd63539ddce3fbdd3f0a375060b6476 Reviewed-on: https://pdfium-review.googlesource.com/6435 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-05-04Give a couple of char to int functions better names.chromium/3090Lei Zhang
- FXSYS_toDecimalDigit() becomes FXSYS_DecimalCharToInt(). - FXSYS_toHexDigit() becomes FXSYS_HexCharToInt(). Change-Id: If4683e8f85f05124b92ff075056cbc295442087d Reviewed-on: https://pdfium-review.googlesource.com/4930 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: 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-04-20Cleanup the fx_extension code.Dan Sinclair
This CL cleans up the fx_extension file. The stream code was moved to fx_stream. IFX_FileAccess was removed and CFX_CRTFileAccess split to its own file. Code shuffled from header to cpp file. Change-Id: I700fdfcc9797cf4e8050cd9ba010ad8854feefbf Reviewed-on: https://pdfium-review.googlesource.com/4371 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@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>
2017-04-07Cleanup string passing in core/fpdf*Tom Sepez
Return strings where possible. Add missing consts to strings passed by ref. Convert non-const cases to pointers. Rename a few methods to be clearer. Change-Id: I86569bc1744f539e6dd67fc73649b272c016328c Reviewed-on: https://pdfium-review.googlesource.com/3951 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-04-05Fix assignment to len.dan sinclair
Sigh, messed up std::min conversion. TBR=npm@chromium.org Bug: pdfium:697 Change-Id: I0091f178b08fa537ebc3962d9349eb46d0aa8a80 Reviewed-on: https://pdfium-review.googlesource.com/3751 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-04-05Use correct length in guard checkdan sinclair
When fixing https://crbug.com/672177 we added a guard that we aren't reading off the end of the file. That guard used the file access Position(). This is the wrong value to compare against as our read position and the file access Position may be different. This CL updates the check to use the correct current file position. Bug: pdfium:697 Change-Id: I68a5eaed2f1f3d65422605f0a8474144cfa7d172 Reviewed-on: https://pdfium-review.googlesource.com/3711 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-04-03Drop FXSYS_ from mem methodsDan Sinclair
This Cl drops the FXSYS_ from mem methods which are the same on all platforms. Bug: pdfium:694 Change-Id: I9d5ae905997dbaaec5aa0b2ae4c07358ed9c6236 Reviewed-on: https://pdfium-review.googlesource.com/3613 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-03-27Guard against lengths greater then input sizeDan Sinclair
If we get a requested length that is longer then the available buffer size we bail as we won't be able to read the needed data anyway. Bug: chromium:672177 Change-Id: Idb41671c07fe758ec0c1d4d6f84ead0a58fa8339 Reviewed-on: https://pdfium-review.googlesource.com/3221 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-03-14Replace FX_CHAR and FX_WCHAR with underlying types.Dan Sinclair
Change-Id: I96e0a20d66b9184d22f64d8e4ce0dadd5a78c1e8 Reviewed-on: https://pdfium-review.googlesource.com/2967 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-01-09Do not parse references with invalid objnumnpm
We should not have valid objects where the object number is CPDF_Object::kInvalidObjNum. BUG=pdfium:609 Review-Url: https://codereview.chromium.org/2610393004
2016-12-15Return unique_ptr from CFX_BinaryBuf::DetachBuffer()tsepez
In turn, make CPDF_Stream() take an unique_ptr. Review-Url: https://codereview.chromium.org/2584683002
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-21Make CPDF_Stream() take unique_ptr's to its dictionary.tsepez
Review-Url: https://codereview.chromium.org/2520493002
2016-11-18Make CPDF_Dictionary use unique pointers.chromium/2926tsepez
Some changes were required to match underlying ctors as invoked by the templated methods. Many release() calls go away, a few WrapUniques() are introduced to avoid going deeper into other code. Review-Url: https://codereview.chromium.org/2510223002
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-16Make CPDF_Array take unique_ptrstsepez
BUG= Review-Url: https://codereview.chromium.org/2498223005
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-04Reland "Remove CPDF_Object::Release() in favor of direct delete"tsepez
This reverts commit f0d5b6c35fa343108a3ab7a25bc2cc2b3cf105b3. Review-Url: https://codereview.chromium.org/2478303002
2016-11-04Revert of Remove CPDF_Object::Release() in favor of direct delete (patchset ↵dsinclair
#11 id:200001 of https://codereview.chromium.org/2384883003/ ) Reason for revert: Looks like it's blocking the roll. https://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_compile_dbg_ng/builds/186619 Original issue's description: > Remove CPDF_Object::Release() in favor of direct delete > > Follow-on once we prove Release always deletes in previous CL. > > Committed: https://pdfium.googlesource.com/pdfium/+/4de3d095c9d9e961f93750cf1ebd489fd515be12 TBR=thestig@chromium.org,tsepez@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review-Url: https://codereview.chromium.org/2478253002