summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser/cpdf_syntax_parser.h
diff options
context:
space:
mode:
authorArtem Strygin <art-snake@yandex-team.ru>2018-07-25 02:28:35 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-07-25 02:28:35 +0000
commit70ddc1ca22ad44a77006491b604a75f6514a4aa8 (patch)
tree1aab47245a415069f425fac877fd361352fb2a27 /core/fpdfapi/parser/cpdf_syntax_parser.h
parent36b2059cae7fc851c9f35babd35ec82a7a5d9694 (diff)
downloadpdfium-70ddc1ca22ad44a77006491b604a75f6514a4aa8.tar.xz
Use document size instead of file size while parsing.
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>
Diffstat (limited to 'core/fpdfapi/parser/cpdf_syntax_parser.h')
-rw-r--r--core/fpdfapi/parser/cpdf_syntax_parser.h19
1 files changed, 14 insertions, 5 deletions
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.h b/core/fpdfapi/parser/cpdf_syntax_parser.h
index 962c32753d..ebd844c3e0 100644
--- a/core/fpdfapi/parser/cpdf_syntax_parser.h
+++ b/core/fpdfapi/parser/cpdf_syntax_parser.h
@@ -60,16 +60,24 @@ class CPDF_SyntaxParser {
ByteString GetNextWord(bool* bIsNumber);
ByteString PeekNextWord(bool* bIsNumber);
- RetainPtr<IFX_SeekableReadStream> GetFileAccess() const;
-
const RetainPtr<CPDF_ReadValidator>& GetValidator() const {
return m_pFileAccess;
}
uint32_t GetDirectNum();
bool GetNextChar(uint8_t& ch);
+ // The document size may be smaller than the file size.
+ // The syntax parser use position relative to document
+ // offset (|m_HeaderOffset|).
+ // The document size will be FileSize - "Header offset".
+ // All offsets was readed from document, should not be great than document
+ // size. Use it for checks instead of real file size.
+ FX_FILESIZE GetDocumentSize() const;
+
+ ByteString ReadString();
+ ByteString ReadHexString();
+
private:
- friend class CPDF_Parser;
friend class CPDF_DataAvail;
friend class cpdf_syntax_parser_ReadHexString_Test;
@@ -84,8 +92,6 @@ class CPDF_SyntaxParser {
const ByteStringView& tag,
bool checkKeyword);
- ByteString ReadString();
- ByteString ReadHexString();
unsigned int ReadEOLMarkers(FX_FILESIZE pos);
FX_FILESIZE FindWordPos(const ByteStringView& word);
FX_FILESIZE FindStreamEndPos();
@@ -99,6 +105,9 @@ class CPDF_SyntaxParser {
ParseType parse_type);
FX_FILESIZE m_Pos;
+ // The syntax parser use position relative to header offset.
+ // The header contains at file start, and can follow after some stuff. We
+ // ignore this stuff.
FX_FILESIZE m_HeaderOffset;
FX_FILESIZE m_FileLen;
WeakPtr<ByteStringPool> m_pPool;