Index: experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp |
=================================================================== |
--- experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp (revision 10419) |
+++ experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp (working copy) |
@@ -83,9 +83,9 @@ |
#define TRACE_HEXSTRING(start,end) |
#endif |
-static const unsigned char* skipPdfWhiteSpaces(int level, const unsigned char* start, const unsigned char* end) { |
+const unsigned char* skipPdfWhiteSpaces(int level, const unsigned char* start, const unsigned char* end) { |
TRACE_INDENT(level, "White Space"); |
- while (start < end && isPdfWhiteSpace(*start)) { |
+ while (start < end && (isPdfWhiteSpace(*start) || *start == kComment_PdfDelimiter)) { |
TRACE_COMMENT(*start); |
if (*start == kComment_PdfDelimiter) { |
// skip the comment until end of line |
@@ -103,7 +103,7 @@ |
} |
// TODO(edisonn) '(' can be used, will it break the string a delimiter or space inside () ? |
-static const unsigned char* endOfPdfToken(int level, const unsigned char* start, const unsigned char* end) { |
+const unsigned char* endOfPdfToken(int level, const unsigned char* start, const unsigned char* end) { |
//int opened brackets |
//TODO(edisonn): what out for special chars, like \n, \032 |
TRACE_INDENT(level, "Token"); |
@@ -636,6 +636,21 @@ |
// TODO(edisonn): laod external streams |
// TODO(edisonn): look at the last filter, to determione how to deal with possible issue |
+ |
+ if (length >= 0) { |
+ const unsigned char* endstream = start + length; |
+ |
+ if (endstream[0] == kCR_PdfWhiteSpace && endstream[1] == kLF_PdfWhiteSpace) { |
+ endstream += 2; |
+ } else if (endstream[0] == kLF_PdfWhiteSpace) { |
+ endstream += 1; |
+ } |
+ |
+ if (strncmp((const char*)endstream, "endstream", strlen("endstream")) != 0) { |
+ length = -1; |
+ } |
+ } |
+ |
if (length < 0) { |
// scan the buffer, until we find first endstream |
// TODO(edisonn): all buffers must have a 0 at the end now, |