Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include "../../../include/fpdfapi/fpdf_parser.h" | 8 #include "../../../include/fpdfapi/fpdf_parser.h" |
| 9 #include "../../../include/fpdfapi/fpdf_module.h" | 9 #include "../../../include/fpdfapi/fpdf_module.h" |
| 10 #include "../../../include/fxcodec/fx_codec.h" | 10 #include "../../../include/fxcodec/fx_codec.h" |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 } | 355 } |
| 356 uint8_t* last_buf = (uint8_t*)src_buf; | 356 uint8_t* last_buf = (uint8_t*)src_buf; |
| 357 FX_DWORD last_size = src_size; | 357 FX_DWORD last_size = src_size; |
| 358 for (int i = 0; i < DecoderList.GetSize(); i++) { | 358 for (int i = 0; i < DecoderList.GetSize(); i++) { |
| 359 int estimated_size = | 359 int estimated_size = |
| 360 i == DecoderList.GetSize() - 1 ? last_estimated_size : 0; | 360 i == DecoderList.GetSize() - 1 ? last_estimated_size : 0; |
| 361 CFX_ByteString decoder = DecoderList[i]; | 361 CFX_ByteString decoder = DecoderList[i]; |
| 362 // Use ToDictionary here because we can push NULL into the ParamList. | 362 // Use ToDictionary here because we can push NULL into the ParamList. |
| 363 CPDF_Dictionary* pParam = | 363 CPDF_Dictionary* pParam = |
| 364 ToDictionary(static_cast<CPDF_Object*>(ParamList[i])); | 364 ToDictionary(static_cast<CPDF_Object*>(ParamList[i])); |
| 365 uint8_t* new_buf = NULL; | 365 uint8_t* new_buf = nullptr; |
| 366 FX_DWORD new_size = (FX_DWORD)-1; | 366 FX_DWORD new_size = (FX_DWORD)-1; |
| 367 int offset = -1; | 367 int offset = -1; |
| 368 if (decoder == FX_BSTRC("FlateDecode") || decoder == FX_BSTRC("Fl")) { | 368 if (decoder == FX_BSTRC("FlateDecode") || decoder == FX_BSTRC("Fl")) { |
| 369 if (bImageAcc && i == DecoderList.GetSize() - 1) { | 369 if (bImageAcc && i == DecoderList.GetSize() - 1) { |
| 370 ImageEncoding = FX_BSTRC("FlateDecode"); | 370 ImageEncoding = FX_BSTRC("FlateDecode"); |
| 371 dest_buf = (uint8_t*)last_buf; | 371 dest_buf = (uint8_t*)last_buf; |
| 372 dest_size = last_size; | 372 dest_size = last_size; |
| 373 pImageParms = pParam; | 373 pImageParms = pParam; |
| 374 return TRUE; | 374 return TRUE; |
| 375 } | 375 } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 387 } else if (decoder == FX_BSTRC("RunLengthDecode") || | 387 } else if (decoder == FX_BSTRC("RunLengthDecode") || |
| 388 decoder == FX_BSTRC("RL")) { | 388 decoder == FX_BSTRC("RL")) { |
| 389 if (bImageAcc && i == DecoderList.GetSize() - 1) { | 389 if (bImageAcc && i == DecoderList.GetSize() - 1) { |
| 390 ImageEncoding = FX_BSTRC("RunLengthDecode"); | 390 ImageEncoding = FX_BSTRC("RunLengthDecode"); |
| 391 dest_buf = (uint8_t*)last_buf; | 391 dest_buf = (uint8_t*)last_buf; |
| 392 dest_size = last_size; | 392 dest_size = last_size; |
| 393 pImageParms = pParam; | 393 pImageParms = pParam; |
| 394 return TRUE; | 394 return TRUE; |
| 395 } | 395 } |
| 396 offset = RunLengthDecode(last_buf, last_size, new_buf, new_size); | 396 offset = RunLengthDecode(last_buf, last_size, new_buf, new_size); |
| 397 } else { | 397 } else if (i == DecoderList.GetSize() - 1) { |
|
jun_fang
2015/11/09 11:09:35
It's too strict checking here.
The filters DCT(JP
Oliver Chang
2015/11/09 20:41:22
Apologies if I misunderstood something, but why is
jun_fang
2015/11/11 10:10:36
- The previous behavior is: all valid or invalid d
jun_fang
2015/11/11 10:13:39
I don't have the permission to access the test fil
Oliver Chang
2015/11/11 17:25:19
Thanks for the clarification!
I see, so we still
| |
| 398 // Check if this is an image decoder. | |
| 398 if (decoder == FX_BSTRC("DCT")) { | 399 if (decoder == FX_BSTRC("DCT")) { |
| 399 decoder = "DCTDecode"; | 400 decoder = "DCTDecode"; |
| 400 } else if (decoder == FX_BSTRC("CCF")) { | 401 } else if (decoder == FX_BSTRC("CCF")) { |
| 401 decoder = "CCITTFaxDecode"; | 402 decoder = "CCITTFaxDecode"; |
| 402 } else if (decoder == FX_BSTRC("Crypt")) { | |
| 403 continue; | |
| 404 } | 403 } |
| 405 ImageEncoding = decoder; | 404 ImageEncoding = decoder; |
| 406 pImageParms = pParam; | 405 pImageParms = pParam; |
| 407 dest_buf = (uint8_t*)last_buf; | 406 dest_buf = (uint8_t*)last_buf; |
| 408 dest_size = last_size; | 407 dest_size = last_size; |
| 409 return TRUE; | 408 return TRUE; |
| 409 } else { | |
| 410 // Ignore all other decoders. | |
| 411 continue; | |
| 410 } | 412 } |
| 411 if (last_buf != src_buf) { | 413 if (last_buf != src_buf) { |
| 412 FX_Free(last_buf); | 414 FX_Free(last_buf); |
| 413 } | 415 } |
| 414 if (offset == -1) { | 416 if (offset == -1) { |
| 415 FX_Free(new_buf); | 417 FX_Free(new_buf); |
| 416 return FALSE; | 418 return FALSE; |
| 417 } | 419 } |
| 418 last_buf = new_buf; | 420 last_buf = new_buf; |
| 419 last_size = new_size; | 421 last_size = new_size; |
| 420 } | 422 } |
| 421 ImageEncoding = ""; | 423 ImageEncoding = ""; |
| 422 pImageParms = NULL; | 424 pImageParms = nullptr; |
| 423 dest_buf = last_buf; | 425 dest_buf = last_buf; |
| 424 dest_size = last_size; | 426 dest_size = last_size; |
| 425 return TRUE; | 427 return TRUE; |
| 426 } | 428 } |
| 427 CFX_WideString PDF_DecodeText(const uint8_t* src_data, | 429 CFX_WideString PDF_DecodeText(const uint8_t* src_data, |
| 428 FX_DWORD src_len, | 430 FX_DWORD src_len, |
| 429 CFX_CharMap* pCharMap) { | 431 CFX_CharMap* pCharMap) { |
| 430 CFX_WideString result; | 432 CFX_WideString result; |
| 431 if (src_len >= 2 && ((src_data[0] == 0xfe && src_data[1] == 0xff) || | 433 if (src_len >= 2 && ((src_data[0] == 0xfe && src_data[1] == 0xff) || |
| 432 (src_data[0] == 0xff && src_data[1] == 0xfe))) { | 434 (src_data[0] == 0xff && src_data[1] == 0xfe))) { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 573 FX_DWORD src_size, | 575 FX_DWORD src_size, |
| 574 uint8_t*& dest_buf, | 576 uint8_t*& dest_buf, |
| 575 FX_DWORD& dest_size) { | 577 FX_DWORD& dest_size) { |
| 576 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); | 578 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); |
| 577 if (pEncoders) { | 579 if (pEncoders) { |
| 578 return pEncoders->GetFlateModule()->FlateOrLZWDecode( | 580 return pEncoders->GetFlateModule()->FlateOrLZWDecode( |
| 579 FALSE, src_buf, src_size, FALSE, 0, 0, 0, 0, 0, dest_buf, dest_size); | 581 FALSE, src_buf, src_size, FALSE, 0, 0, 0, 0, 0, dest_buf, dest_size); |
| 580 } | 582 } |
| 581 return 0; | 583 return 0; |
| 582 } | 584 } |
| OLD | NEW |