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 "fpdfsdk/javascript/JS_GlobalData.h" | 7 #include "fpdfsdk/javascript/JS_GlobalData.h" |
8 | 8 |
9 #include "core/fdrm/crypto/include/fx_crypt.h" | 9 #include "core/fdrm/crypto/include/fx_crypt.h" |
10 #include "fpdfsdk/include/javascript/IJavaScript.h" | |
11 #include "third_party/base/stl_util.h" | 10 #include "third_party/base/stl_util.h" |
12 | 11 |
13 #define JS_MAXGLOBALDATA (1024 * 4 - 8) | 12 #define JS_MAXGLOBALDATA (1024 * 4 - 8) |
14 | 13 |
15 /* --------------------- CJS_GlobalVariableArray --------------------- */ | |
16 | |
17 CJS_GlobalVariableArray::CJS_GlobalVariableArray() {} | 14 CJS_GlobalVariableArray::CJS_GlobalVariableArray() {} |
18 | 15 |
19 CJS_GlobalVariableArray::~CJS_GlobalVariableArray() { | 16 CJS_GlobalVariableArray::~CJS_GlobalVariableArray() { |
20 Empty(); | 17 Empty(); |
21 } | 18 } |
22 | 19 |
23 void CJS_GlobalVariableArray::Copy(const CJS_GlobalVariableArray& array) { | 20 void CJS_GlobalVariableArray::Copy(const CJS_GlobalVariableArray& array) { |
24 Empty(); | 21 Empty(); |
25 for (int i = 0, sz = array.Count(); i < sz; i++) { | 22 for (int i = 0, sz = array.Count(); i < sz; i++) { |
26 CJS_KeyValue* pOldObjData = array.GetAt(i); | 23 CJS_KeyValue* pOldObjData = array.GetAt(i); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 CJS_KeyValue* CJS_GlobalVariableArray::GetAt(int index) const { | 71 CJS_KeyValue* CJS_GlobalVariableArray::GetAt(int index) const { |
75 return array.GetAt(index); | 72 return array.GetAt(index); |
76 } | 73 } |
77 | 74 |
78 void CJS_GlobalVariableArray::Empty() { | 75 void CJS_GlobalVariableArray::Empty() { |
79 for (int i = 0, sz = array.GetSize(); i < sz; i++) | 76 for (int i = 0, sz = array.GetSize(); i < sz; i++) |
80 delete array.GetAt(i); | 77 delete array.GetAt(i); |
81 array.RemoveAll(); | 78 array.RemoveAll(); |
82 } | 79 } |
83 | 80 |
84 /* -------------------------- CJS_GlobalData -------------------------- */ | |
85 | |
86 #define READER_JS_GLOBALDATA_FILENAME L"Reader_JsGlobal.Data" | 81 #define READER_JS_GLOBALDATA_FILENAME L"Reader_JsGlobal.Data" |
87 #define PHANTOM_JS_GLOBALDATA_FILENAME L"Phantom_JsGlobal.Data" | 82 #define PHANTOM_JS_GLOBALDATA_FILENAME L"Phantom_JsGlobal.Data" |
88 #define SDK_JS_GLOBALDATA_FILENAME L"SDK_JsGlobal.Data" | 83 #define SDK_JS_GLOBALDATA_FILENAME L"SDK_JsGlobal.Data" |
89 | 84 |
90 static const uint8_t JS_RC4KEY[] = { | 85 static const uint8_t JS_RC4KEY[] = { |
91 0x19, 0xa8, 0xe8, 0x01, 0xf6, 0xa8, 0xb6, 0x4d, 0x82, 0x04, 0x45, 0x6d, | 86 0x19, 0xa8, 0xe8, 0x01, 0xf6, 0xa8, 0xb6, 0x4d, 0x82, 0x04, 0x45, 0x6d, |
92 0xb4, 0xcf, 0xd7, 0x77, 0x67, 0xf9, 0x75, 0x9f, 0xf0, 0xe0, 0x1e, 0x51, | 87 0xb4, 0xcf, 0xd7, 0x77, 0x67, 0xf9, 0x75, 0x9f, 0xf0, 0xe0, 0x1e, 0x51, |
93 0xee, 0x46, 0xfd, 0x0b, 0xc9, 0x93, 0x25, 0x55, 0x4a, 0xee, 0xe0, 0x16, | 88 0xee, 0x46, 0xfd, 0x0b, 0xc9, 0x93, 0x25, 0x55, 0x4a, 0xee, 0xe0, 0x16, |
94 0xd0, 0xdf, 0x8c, 0xfa, 0x2a, 0xa9, 0x49, 0xfd, 0x97, 0x1c, 0x0e, 0x22, | 89 0xd0, 0xdf, 0x8c, 0xfa, 0x2a, 0xa9, 0x49, 0xfd, 0x97, 0x1c, 0x0e, 0x22, |
95 0x13, 0x28, 0x7c, 0xaf, 0xc4, 0xfc, 0x9c, 0x12, 0x65, 0x8c, 0x4e, 0x5b, | 90 0x13, 0x28, 0x7c, 0xaf, 0xc4, 0xfc, 0x9c, 0x12, 0x65, 0x8c, 0x4e, 0x5b, |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 case JS_GLOBALDATA_TYPE_NULL: { | 449 case JS_GLOBALDATA_TYPE_NULL: { |
455 uint32_t dwNameLen = (uint32_t)name.GetLength(); | 450 uint32_t dwNameLen = (uint32_t)name.GetLength(); |
456 sData.AppendBlock(&dwNameLen, sizeof(uint32_t)); | 451 sData.AppendBlock(&dwNameLen, sizeof(uint32_t)); |
457 sData.AppendString(name); | 452 sData.AppendString(name); |
458 sData.AppendBlock(&wType, sizeof(uint32_t)); | 453 sData.AppendBlock(&wType, sizeof(uint32_t)); |
459 } break; | 454 } break; |
460 default: | 455 default: |
461 break; | 456 break; |
462 } | 457 } |
463 } | 458 } |
OLD | NEW |