Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Side by Side Diff: experimental/PdfViewer/pdfparser/native/SkPdfNativeTokenizer.cpp

Issue 18112023: pdfviewer: ignore more bad stauff in pdfs (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 #include "SkPdfNativeTokenizer.h" 2 #include "SkPdfNativeTokenizer.h"
3 #include "SkPdfObject.h" 3 #include "SkPdfObject.h"
4 #include "SkPdfConfig.h" 4 #include "SkPdfConfig.h"
5 5
6 #include "SkPdfStreamCommonDictionary_autogen.h" 6 #include "SkPdfStreamCommonDictionary_autogen.h"
7 7
8 static unsigned char* skipPdfWhiteSpaces(unsigned char* start, unsigned char* en d) { 8 static unsigned char* skipPdfWhiteSpaces(unsigned char* start, unsigned char* en d) {
9 while (start < end && isPdfWhiteSpace(*start)) { 9 while (start < end && isPdfWhiteSpace(*start)) {
10 if (*start == kComment_PdfDelimiter) { 10 if (*start == kComment_PdfDelimiter) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // we are sure they are not references! 62 // we are sure they are not references!
63 if (newObj->isKeywordReference() && array->size() >= 2 && array->objAtAI ndex(array->size() - 1)->isInteger() && array->objAtAIndex(array->size() - 2)->i sInteger()) { 63 if (newObj->isKeywordReference() && array->size() >= 2 && array->objAtAI ndex(array->size() - 1)->isInteger() && array->objAtAIndex(array->size() - 2)->i sInteger()) {
64 SkPdfObject* gen = array->removeLastInArray(); 64 SkPdfObject* gen = array->removeLastInArray();
65 SkPdfObject* id = array->removeLastInArray(); 65 SkPdfObject* id = array->removeLastInArray();
66 newObj->reset(); 66 newObj->reset();
67 SkPdfObject::makeReference((unsigned int)id->intValue(), (unsigned i nt)gen->intValue(), newObj); 67 SkPdfObject::makeReference((unsigned int)id->intValue(), (unsigned i nt)gen->intValue(), newObj);
68 } 68 }
69 array->appendInArray(newObj); 69 array->appendInArray(newObj);
70 } 70 }
71 // TODO(edisonn): report not reached, we should never get here 71 // TODO(edisonn): report not reached, we should never get here
72 SkASSERT(false); 72 // TODO(edisonn): there might be a bug here, enable an assert and run it on files
73 // or it might be that the files were actually corrupted
73 return start; 74 return start;
74 } 75 }
75 76
76 // When we read strings we will rewrite the string so we will reuse the memory 77 // When we read strings we will rewrite the string so we will reuse the memory
77 // when we start to read the string, we already consumed the opened bracket 78 // when we start to read the string, we already consumed the opened bracket
78 static unsigned char* readString(unsigned char* start, unsigned char* end, SkPdf Object* str) { 79 static unsigned char* readString(unsigned char* start, unsigned char* end, SkPdf Object* str) {
79 unsigned char* out = start; 80 unsigned char* out = start;
80 unsigned char* in = start; 81 unsigned char* in = start;
81 82
82 int openRoundBrackets = 0; 83 int openRoundBrackets = 0;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 out++; 164 out++;
164 } 165 }
165 } 166 }
166 break; 167 break;
167 168
168 default: 169 default:
169 // Per spec, backslash is ignored is escaped ch is unkno wn 170 // Per spec, backslash is ignored is escaped ch is unkno wn
170 in++; 171 in++;
171 break; 172 break;
172 } 173 }
174 } else {
175 in++;
173 } 176 }
174 } else { 177 } else {
175 // TODO(edisonn): perf, avoid copy into itself, maybe first do a sim ple scan until found backslash ? 178 // TODO(edisonn): perf, avoid copy into itself, maybe first do a sim ple scan until found backslash ?
176 // we could have one look that first just inc current, and when we f ind the backslash 179 // we could have one look that first just inc current, and when we f ind the backslash
177 // we go to this loop 180 // we go to this loop
178 *in = *out; 181 *in = *out;
179 in++; 182 in++;
180 out++; 183 out++;
181 } 184 }
182 } 185 }
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 if (fEmpty) { 767 if (fEmpty) {
765 #ifdef PDF_TRACE 768 #ifdef PDF_TRACE
766 printf("EMPTY TOKENIZER\n"); 769 printf("EMPTY TOKENIZER\n");
767 #endif 770 #endif
768 return false; 771 return false;
769 } 772 }
770 773
771 return readTokenCore(token); 774 return readTokenCore(token);
772 } 775 }
773 776
OLDNEW
« no previous file with comments | « experimental/PdfViewer/pdfparser/native/SkNativeParsedPDF.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698