pdfjs-dist 2.0.550 → 2.3.200
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pdfjs-dist might be problematic. Click here for more details.
- package/CODE_OF_CONDUCT.md +15 -0
- package/bower.json +1 -1
- package/build/pdf.js +21618 -14369
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +22758 -11399
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +1 -1
- package/image_decoders/pdf.image_decoders.js +11500 -0
- package/image_decoders/pdf.image_decoders.js.map +1 -0
- package/image_decoders/pdf.image_decoders.min.js +1 -0
- package/lib/core/annotation.js +767 -258
- package/lib/core/arithmetic_decoder.js +275 -245
- package/lib/core/bidi.js +65 -6
- package/lib/core/ccitt.js +173 -18
- package/lib/core/ccitt_stream.js +15 -6
- package/lib/core/cff_parser.js +433 -61
- package/lib/core/charsets.js +5 -4
- package/lib/core/chunked_stream.js +428 -157
- package/lib/core/cmap.js +326 -87
- package/lib/core/colorspace.js +874 -594
- package/lib/core/core_utils.js +173 -0
- package/lib/core/crypto.js +290 -45
- package/lib/core/document.js +575 -272
- package/lib/core/encodings.js +19 -10
- package/lib/core/evaluator.js +1032 -351
- package/lib/core/font_renderer.js +331 -97
- package/lib/core/fonts.js +813 -196
- package/lib/core/function.js +253 -27
- package/lib/core/glyphlist.js +5 -3
- package/lib/core/image.js +169 -62
- package/lib/core/image_utils.js +111 -0
- package/lib/core/jbig2.js +502 -72
- package/lib/core/jbig2_stream.js +19 -8
- package/lib/core/jpeg_stream.js +38 -13
- package/lib/core/jpg.js +293 -52
- package/lib/core/jpx.js +419 -12
- package/lib/core/jpx_stream.js +18 -6
- package/lib/core/metrics.js +15 -15
- package/lib/core/murmurhash3.js +56 -34
- package/lib/core/obj.js +1368 -500
- package/lib/core/operator_list.js +159 -43
- package/lib/core/parser.js +544 -199
- package/lib/core/pattern.js +170 -21
- package/lib/core/pdf_manager.js +324 -134
- package/lib/core/primitives.js +169 -61
- package/lib/core/ps_parser.js +134 -45
- package/lib/core/standard_fonts.js +17 -17
- package/lib/core/stream.js +327 -34
- package/lib/core/type1_parser.js +148 -8
- package/lib/core/unicode.js +32 -5
- package/lib/core/worker.js +215 -229
- package/lib/core/worker_stream.js +277 -0
- package/lib/display/annotation_layer.js +618 -192
- package/lib/display/api.js +1798 -882
- package/lib/display/api_compatibility.js +5 -10
- package/lib/display/canvas.js +366 -45
- package/lib/display/content_disposition.js +71 -24
- package/lib/display/display_utils.js +777 -0
- package/lib/display/fetch_stream.js +205 -87
- package/lib/display/font_loader.js +468 -236
- package/lib/display/metadata.js +38 -16
- package/lib/display/network.js +635 -428
- package/lib/display/network_utils.js +38 -19
- package/lib/display/node_stream.js +367 -175
- package/lib/display/pattern_helper.js +103 -36
- package/lib/display/svg.js +1232 -519
- package/lib/display/text_layer.js +208 -75
- package/lib/display/transport_stream.js +345 -94
- package/lib/display/webgl.js +64 -18
- package/lib/display/worker_options.js +5 -4
- package/lib/display/xml_parser.js +166 -53
- package/lib/examples/node/domstubs.js +60 -4
- package/lib/pdf.js +35 -14
- package/lib/pdf.worker.js +5 -3
- package/lib/shared/compatibility.js +170 -572
- package/lib/shared/global_scope.js +2 -2
- package/lib/shared/is_node.js +4 -4
- package/lib/shared/message_handler.js +216 -163
- package/lib/shared/streams_polyfill.js +21 -17
- package/lib/shared/util.js +495 -385
- package/lib/test/unit/annotation_spec.js +1464 -401
- package/lib/test/unit/api_spec.js +718 -361
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +54 -11
- package/lib/test/unit/clitests_helper.js +9 -10
- package/lib/test/unit/cmap_spec.js +95 -41
- package/lib/test/unit/colorspace_spec.js +115 -63
- package/lib/test/unit/core_utils_spec.js +191 -0
- package/lib/test/unit/crypto_spec.js +17 -5
- package/lib/test/unit/custom_spec.js +43 -55
- package/lib/test/unit/display_svg_spec.js +34 -18
- package/lib/test/unit/display_utils_spec.js +273 -0
- package/lib/test/unit/document_spec.js +8 -13
- package/lib/test/unit/encodings_spec.js +25 -45
- package/lib/test/unit/evaluator_spec.js +59 -20
- package/lib/test/unit/fetch_stream_spec.js +111 -0
- package/lib/test/unit/function_spec.js +17 -5
- package/lib/test/unit/jasmine-boot.js +33 -20
- package/lib/test/unit/message_handler_spec.js +30 -13
- package/lib/test/unit/metadata_spec.js +71 -11
- package/lib/test/unit/murmurhash3_spec.js +3 -3
- package/lib/test/unit/network_spec.js +22 -55
- package/lib/test/unit/network_utils_spec.js +105 -14
- package/lib/test/unit/node_stream_spec.js +58 -34
- package/lib/test/unit/parser_spec.js +162 -71
- package/lib/test/unit/pdf_find_controller_spec.js +230 -0
- package/lib/test/unit/pdf_find_utils_spec.js +63 -0
- package/lib/test/unit/pdf_history_spec.js +21 -9
- package/lib/test/unit/primitives_spec.js +55 -22
- package/lib/test/unit/stream_spec.js +12 -4
- package/lib/test/unit/test_utils.js +273 -56
- package/lib/test/unit/testreporter.js +21 -3
- package/lib/test/unit/type1_parser_spec.js +9 -7
- package/lib/test/unit/ui_utils_spec.js +236 -36
- package/lib/test/unit/unicode_spec.js +18 -15
- package/lib/test/unit/util_spec.js +87 -128
- package/lib/web/annotation_layer_builder.js +39 -22
- package/lib/web/app.js +1252 -609
- package/lib/web/app_options.js +103 -65
- package/lib/web/base_viewer.js +522 -242
- package/lib/web/chromecom.js +259 -117
- package/lib/web/debugger.js +166 -22
- package/lib/web/download_manager.js +31 -12
- package/lib/web/firefox_print_service.js +27 -14
- package/lib/web/firefoxcom.js +318 -78
- package/lib/web/genericcom.js +89 -30
- package/lib/web/genericl10n.js +142 -30
- package/lib/web/grab_to_pan.js +28 -4
- package/lib/web/interfaces.js +174 -47
- package/lib/web/overlay_manager.js +235 -85
- package/lib/web/password_prompt.js +22 -14
- package/lib/web/pdf_attachment_viewer.js +38 -18
- package/lib/web/pdf_cursor_tools.js +39 -16
- package/lib/web/pdf_document_properties.js +255 -136
- package/lib/web/pdf_find_bar.js +84 -40
- package/lib/web/pdf_find_controller.js +495 -184
- package/lib/web/pdf_find_utils.js +111 -0
- package/lib/web/pdf_history.js +190 -53
- package/lib/web/pdf_link_service.js +144 -79
- package/lib/web/pdf_outline_viewer.js +124 -47
- package/lib/web/pdf_page_view.js +194 -74
- package/lib/web/pdf_presentation_mode.js +99 -34
- package/lib/web/pdf_print_service.js +59 -13
- package/lib/web/pdf_rendering_queue.js +28 -9
- package/lib/web/pdf_sidebar.js +144 -81
- package/lib/web/pdf_sidebar_resizer.js +42 -16
- package/lib/web/pdf_single_page_viewer.js +74 -66
- package/lib/web/pdf_thumbnail_view.js +104 -33
- package/lib/web/pdf_thumbnail_viewer.js +66 -26
- package/lib/web/pdf_viewer.component.js +112 -32
- package/lib/web/pdf_viewer.js +82 -87
- package/lib/web/preferences.js +284 -91
- package/lib/web/secondary_toolbar.js +132 -59
- package/lib/web/text_layer_builder.js +134 -59
- package/lib/web/toolbar.js +80 -43
- package/lib/web/ui_utils.js +400 -134
- package/lib/web/view_history.js +215 -67
- package/lib/web/viewer_compatibility.js +3 -8
- package/package.json +3 -2
- package/web/pdf_viewer.css +23 -15
- package/web/pdf_viewer.js +3429 -1245
- package/web/pdf_viewer.js.map +1 -1
- package/external/streams/streams-lib.js +0 -3962
- package/lib/display/dom_utils.js +0 -429
- package/lib/test/unit/dom_utils_spec.js +0 -89
- package/lib/test/unit/fonts_spec.js +0 -81
- package/lib/web/dom_events.js +0 -137
@@ -2,7 +2,7 @@
|
|
2
2
|
* @licstart The following is the entire license notice for the
|
3
3
|
* Javascript code in this page
|
4
4
|
*
|
5
|
-
* Copyright
|
5
|
+
* Copyright 2019 Mozilla Foundation
|
6
6
|
*
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
8
|
* you may not use this file except in compliance with the License.
|
@@ -19,15 +19,15 @@
|
|
19
19
|
* @licend The above is the entire license notice for the
|
20
20
|
* Javascript code in this page
|
21
21
|
*/
|
22
|
-
|
22
|
+
"use strict";
|
23
23
|
|
24
|
-
var
|
24
|
+
var _util = require("../../shared/util");
|
25
25
|
|
26
|
-
var
|
26
|
+
var _api = require("../../display/api");
|
27
27
|
|
28
|
-
var
|
28
|
+
var _message_handler = require("../../shared/message_handler");
|
29
29
|
|
30
|
-
|
30
|
+
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
31
31
|
|
32
32
|
describe('message_handler', function () {
|
33
33
|
function sleep(ticks) {
|
@@ -35,12 +35,13 @@ describe('message_handler', function () {
|
|
35
35
|
return ticks && sleep(ticks - 1);
|
36
36
|
});
|
37
37
|
}
|
38
|
+
|
38
39
|
describe('sendWithStream', function () {
|
39
40
|
it('should return a ReadableStream', function () {
|
40
41
|
var port = new _api.LoopbackPort();
|
41
42
|
var messageHandler1 = new _message_handler.MessageHandler('main', 'worker', port);
|
42
43
|
var readable = messageHandler1.sendWithStream('fakeHandler');
|
43
|
-
expect(
|
44
|
+
expect(_typeof(readable)).toEqual('object');
|
44
45
|
expect(_typeof(readable.getReader)).toEqual('function');
|
45
46
|
});
|
46
47
|
it('should read using a reader', function (done) {
|
@@ -52,9 +53,11 @@ describe('message_handler', function () {
|
|
52
53
|
sink.onPull = function () {
|
53
54
|
log += 'p';
|
54
55
|
};
|
56
|
+
|
55
57
|
sink.onCancel = function (reason) {
|
56
58
|
log += 'c';
|
57
59
|
};
|
60
|
+
|
58
61
|
sink.ready.then(function () {
|
59
62
|
sink.enqueue('hi');
|
60
63
|
return sink.ready;
|
@@ -94,9 +97,11 @@ describe('message_handler', function () {
|
|
94
97
|
sink.onPull = function () {
|
95
98
|
log += 'p';
|
96
99
|
};
|
100
|
+
|
97
101
|
sink.onCancel = function (reason) {
|
98
102
|
log += 'c';
|
99
103
|
};
|
104
|
+
|
100
105
|
log += '0';
|
101
106
|
sink.ready.then(function () {
|
102
107
|
log += '1';
|
@@ -130,7 +135,7 @@ describe('message_handler', function () {
|
|
130
135
|
return sleep(10);
|
131
136
|
}).then(function () {
|
132
137
|
expect(log).toEqual('01p2');
|
133
|
-
return reader.cancel();
|
138
|
+
return reader.cancel(new _util.AbortException('reader cancelled.'));
|
134
139
|
}).then(function () {
|
135
140
|
expect(log).toEqual('01p2c4');
|
136
141
|
done();
|
@@ -144,15 +149,19 @@ describe('message_handler', function () {
|
|
144
149
|
sink.onPull = function () {
|
145
150
|
log += 'p';
|
146
151
|
};
|
152
|
+
|
147
153
|
sink.onCancel = function (reason) {
|
148
154
|
log += 'c';
|
149
155
|
};
|
156
|
+
|
157
|
+
log += '0';
|
150
158
|
sink.ready.then(function () {
|
159
|
+
log += '1';
|
151
160
|
sink.enqueue([1, 2, 3, 4], 4);
|
152
161
|
return sink.ready;
|
153
162
|
}).then(function () {
|
154
|
-
log += '
|
155
|
-
sink.error('
|
163
|
+
log += 'e';
|
164
|
+
sink.error(new Error('should not read when errored'));
|
156
165
|
});
|
157
166
|
});
|
158
167
|
var messageHandler1 = new _message_handler.MessageHandler('main', 'worker', port);
|
@@ -164,14 +173,16 @@ describe('message_handler', function () {
|
|
164
173
|
});
|
165
174
|
var reader = readable.getReader();
|
166
175
|
sleep(10).then(function () {
|
167
|
-
expect(log).toEqual('');
|
176
|
+
expect(log).toEqual('01');
|
168
177
|
return reader.read();
|
169
178
|
}).then(function (result) {
|
170
179
|
expect(result.value).toEqual([1, 2, 3, 4]);
|
171
180
|
expect(result.done).toEqual(false);
|
172
181
|
return reader.read();
|
173
|
-
})
|
174
|
-
expect(
|
182
|
+
})["catch"](function (reason) {
|
183
|
+
expect(log).toEqual('01pe');
|
184
|
+
expect(reason instanceof _util.UnknownErrorException).toEqual(true);
|
185
|
+
expect(reason.message).toEqual('should not read when errored');
|
175
186
|
done();
|
176
187
|
});
|
177
188
|
});
|
@@ -183,9 +194,11 @@ describe('message_handler', function () {
|
|
183
194
|
sink.onPull = function () {
|
184
195
|
log += 'p';
|
185
196
|
};
|
197
|
+
|
186
198
|
sink.onCancel = function (reason) {
|
187
199
|
log += 'c';
|
188
200
|
};
|
201
|
+
|
189
202
|
log += '0';
|
190
203
|
sink.ready.then(function () {
|
191
204
|
log += '1';
|
@@ -238,9 +251,11 @@ describe('message_handler', function () {
|
|
238
251
|
sink.onPull = function () {
|
239
252
|
log += 'p';
|
240
253
|
};
|
254
|
+
|
241
255
|
sink.onCancel = function (reason) {
|
242
256
|
log += 'c';
|
243
257
|
};
|
258
|
+
|
244
259
|
log += '0';
|
245
260
|
sink.ready.then(function () {
|
246
261
|
log += '1';
|
@@ -295,9 +310,11 @@ describe('message_handler', function () {
|
|
295
310
|
sink.onPull = function () {
|
296
311
|
log += 'p';
|
297
312
|
};
|
313
|
+
|
298
314
|
sink.onCancel = function (reason) {
|
299
315
|
log += 'c';
|
300
316
|
};
|
317
|
+
|
301
318
|
log += '0';
|
302
319
|
sink.ready.then(function () {
|
303
320
|
log += '1';
|
@@ -2,7 +2,7 @@
|
|
2
2
|
* @licstart The following is the entire license notice for the
|
3
3
|
* Javascript code in this page
|
4
4
|
*
|
5
|
-
* Copyright
|
5
|
+
* Copyright 2019 Mozilla Foundation
|
6
6
|
*
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
8
|
* you may not use this file except in compliance with the License.
|
@@ -19,32 +19,38 @@
|
|
19
19
|
* @licend The above is the entire license notice for the
|
20
20
|
* Javascript code in this page
|
21
21
|
*/
|
22
|
-
|
22
|
+
"use strict";
|
23
23
|
|
24
|
-
var
|
24
|
+
var _util = require("../../shared/util");
|
25
|
+
|
26
|
+
var _metadata = require("../../display/metadata");
|
25
27
|
|
26
28
|
describe('metadata', function () {
|
27
29
|
it('should handle valid metadata', function () {
|
28
|
-
var
|
29
|
-
var metadata = new _metadata.Metadata(
|
30
|
+
var data = '<x:xmpmeta xmlns:x=\'adobe:ns:meta/\'>' + '<rdf:RDF xmlns:rdf=\'http://www.w3.org/1999/02/22-rdf-syntax-ns#\'>' + '<rdf:Description xmlns:dc=\'http://purl.org/dc/elements/1.1/\'>' + '<dc:title><rdf:Alt><rdf:li xml:lang="x-default">Foo bar baz</rdf:li>' + '</rdf:Alt></dc:title></rdf:Description></rdf:RDF></x:xmpmeta>';
|
31
|
+
var metadata = new _metadata.Metadata(data);
|
30
32
|
expect(metadata.has('dc:title')).toBeTruthy();
|
31
33
|
expect(metadata.has('dc:qux')).toBeFalsy();
|
32
34
|
expect(metadata.get('dc:title')).toEqual('Foo bar baz');
|
33
35
|
expect(metadata.get('dc:qux')).toEqual(null);
|
34
|
-
expect(metadata.getAll()).toEqual({
|
36
|
+
expect(metadata.getAll()).toEqual({
|
37
|
+
'dc:title': 'Foo bar baz'
|
38
|
+
});
|
35
39
|
});
|
36
40
|
it('should repair and handle invalid metadata', function () {
|
37
|
-
var
|
38
|
-
var metadata = new _metadata.Metadata(
|
41
|
+
var data = '<x:xmpmeta xmlns:x=\'adobe:ns:meta/\'>' + '<rdf:RDF xmlns:rdf=\'http://www.w3.org/1999/02/22-rdf-syntax-ns#\'>' + '<rdf:Description xmlns:dc=\'http://purl.org/dc/elements/1.1/\'>' + '<dc:title>\\376\\377\\000P\\000D\\000F\\000&</dc:title>' + '</rdf:Description></rdf:RDF></x:xmpmeta>';
|
42
|
+
var metadata = new _metadata.Metadata(data);
|
39
43
|
expect(metadata.has('dc:title')).toBeTruthy();
|
40
44
|
expect(metadata.has('dc:qux')).toBeFalsy();
|
41
45
|
expect(metadata.get('dc:title')).toEqual('PDF&');
|
42
46
|
expect(metadata.get('dc:qux')).toEqual(null);
|
43
|
-
expect(metadata.getAll()).toEqual({
|
47
|
+
expect(metadata.getAll()).toEqual({
|
48
|
+
'dc:title': 'PDF&'
|
49
|
+
});
|
44
50
|
});
|
45
51
|
it('should repair and handle invalid metadata (bug 1424938)', function () {
|
46
|
-
var
|
47
|
-
var metadata = new _metadata.Metadata(
|
52
|
+
var data = '<x:xmpmeta xmlns:x=\'adobe:ns:meta/\' ' + 'x:xmptk=\'XMP toolkit 2.9.1-13, framework 1.6\'>' + '<rdf:RDF xmlns:rdf=\'http://www.w3.org/1999/02/22-rdf-syntax-ns#\' ' + 'xmlns:iX=\'http://ns.adobe.com/iX/1.0/\'>' + '<rdf:Description rdf:about=\'61652fa7-fc1f-11dd-0000-ce81d41f9ecf\' ' + 'xmlns:pdf=\'http://ns.adobe.com/pdf/1.3/\' ' + 'pdf:Producer=\'GPL Ghostscript 8.63\'/>' + '<rdf:Description rdf:about=\'61652fa7-fc1f-11dd-0000-ce81d41f9ecf\' ' + 'xmlns:xap=\'http://ns.adobe.com/xap/1.0/\' ' + 'xap:ModifyDate=\'2009-02-13T12:42:54+01:00\' ' + 'xap:CreateDate=\'2009-02-13T12:42:54+01:00\'>' + '<xap:CreatorTool>\\376\\377\\000P\\000D\\000F\\000C\\000r\\000e\\000a' + '\\000t\\000o\\000r\\000 \\000V\\000e\\000r\\000s\\000i\\000o\\000n' + '\\000 \\0000\\000.\\0009\\000.\\0006</xap:CreatorTool>' + '</rdf:Description><rdf:Description ' + 'rdf:about=\'61652fa7-fc1f-11dd-0000-ce81d41f9ecf\' ' + 'xmlns:xapMM=\'http://ns.adobe.com/xap/1.0/mm/\' ' + 'xapMM:DocumentID=\'61652fa7-fc1f-11dd-0000-ce81d41f9ecf\'/>' + '<rdf:Description rdf:about=\'61652fa7-fc1f-11dd-0000-ce81d41f9ecf\' ' + 'xmlns:dc=\'http://purl.org/dc/elements/1.1/\' ' + 'dc:format=\'application/pdf\'><dc:title><rdf:Alt>' + '<rdf:li xml:lang=\'x-default\'>\\376\\377\\000L\\000'\\000O\\000d' + '\\000i\\000s\\000s\\000e\\000e\\000 \\000t\\000h\\000\\351\\000m\\000a' + '\\000t\\000i\\000q\\000u\\000e\\000 \\000l\\000o\\000g\\000o\\000 ' + '\\000O\\000d\\000i\\000s\\000s\\000\\351\\000\\351\\000 \\000-\\000 ' + '\\000d\\000\\351\\000c\\000e\\000m\\000b\\000r\\000e\\000 \\0002\\0000' + '\\0000\\0008\\000.\\000p\\000u\\000b</rdf:li></rdf:Alt></dc:title>' + '<dc:creator><rdf:Seq><rdf:li>\\376\\377\\000O\\000D\\000I\\000S' + '</rdf:li></rdf:Seq></dc:creator></rdf:Description></rdf:RDF>' + '</x:xmpmeta>';
|
53
|
+
var metadata = new _metadata.Metadata(data);
|
48
54
|
expect(metadata.has('dc:title')).toBeTruthy();
|
49
55
|
expect(metadata.has('dc:qux')).toBeFalsy();
|
50
56
|
expect(metadata.get('dc:title')).toEqual('L\'Odissee thématique logo Odisséé - décembre 2008.pub');
|
@@ -55,4 +61,58 @@ describe('metadata', function () {
|
|
55
61
|
'xap:creatortool': 'PDFCreator Version 0.9.6'
|
56
62
|
});
|
57
63
|
});
|
64
|
+
it('should gracefully handle incomplete tags (issue 8884)', function () {
|
65
|
+
var data = '<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d' + '<x:xmpmeta xmlns:x="adobe:ns:meta/">' + '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">' + '<rdf:Description rdf:about=""' + 'xmlns:pdfx="http://ns.adobe.com/pdfx/1.3/">' + '</rdf:Description>' + '<rdf:Description rdf:about=""' + 'xmlns:xap="http://ns.adobe.com/xap/1.0/">' + '<xap:ModifyDate>2010-03-25T11:20:09-04:00</xap:ModifyDate>' + '<xap:CreateDate>2010-03-25T11:20:09-04:00</xap:CreateDate>' + '<xap:MetadataDate>2010-03-25T11:20:09-04:00</xap:MetadataDate>' + '</rdf:Description>' + '<rdf:Description rdf:about=""' + 'xmlns:dc="http://purl.org/dc/elements/1.1/">' + '<dc:format>application/pdf</dc:format>' + '</rdf:Description>' + '<rdf:Description rdf:about=""' + 'xmlns:pdfaid="http://www.aiim.org/pdfa/ns/id/">' + '<pdfaid:part>1</pdfaid:part>' + '<pdfaid:conformance>A</pdfaid:conformance>' + '</rdf:Description>' + '</rdf:RDF>' + '</x:xmpmeta>' + '<?xpacket end="w"?>';
|
66
|
+
var metadata = new _metadata.Metadata(data);
|
67
|
+
expect((0, _util.isEmptyObj)(metadata.getAll())).toEqual(true);
|
68
|
+
});
|
69
|
+
it('should gracefully handle "junk" before the actual metadata (issue 10395)', function () {
|
70
|
+
var data = '<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>' + '<x:xmpmeta x:xmptk="TallComponents PDFObjects 1.0" ' + 'xmlns:x="adobe:ns:meta/">' + '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">' + '<rdf:Description rdf:about="" ' + 'xmlns:pdf="http://ns.adobe.com/pdf/1.3/">' + '<pdf:Producer>PDFKit.NET 4.0.102.0</pdf:Producer>' + '<pdf:Keywords></pdf:Keywords>' + '<pdf:PDFVersion>1.7</pdf:PDFVersion></rdf:Description>' + '<rdf:Description rdf:about="" ' + 'xmlns:xap="http://ns.adobe.com/xap/1.0/">' + '<xap:CreateDate>2018-12-27T13:50:36-08:00</xap:CreateDate>' + '<xap:ModifyDate>2018-12-27T13:50:38-08:00</xap:ModifyDate>' + '<xap:CreatorTool></xap:CreatorTool>' + '<xap:MetadataDate>2018-12-27T13:50:38-08:00</xap:MetadataDate>' + '</rdf:Description><rdf:Description rdf:about="" ' + 'xmlns:dc="http://purl.org/dc/elements/1.1/">' + '<dc:creator><rdf:Seq><rdf:li></rdf:li></rdf:Seq></dc:creator>' + '<dc:subject><rdf:Bag /></dc:subject>' + '<dc:description><rdf:Alt><rdf:li xml:lang="x-default">' + '</rdf:li></rdf:Alt></dc:description>' + '<dc:title><rdf:Alt><rdf:li xml:lang="x-default"></rdf:li>' + '</rdf:Alt></dc:title><dc:format>application/pdf</dc:format>' + '</rdf:Description></rdf:RDF></x:xmpmeta><?xpacket end="w"?>';
|
71
|
+
var metadata = new _metadata.Metadata(data);
|
72
|
+
expect(metadata.has('dc:title')).toBeTruthy();
|
73
|
+
expect(metadata.has('dc:qux')).toBeFalsy();
|
74
|
+
expect(metadata.get('dc:title')).toEqual('');
|
75
|
+
expect(metadata.get('dc:qux')).toEqual(null);
|
76
|
+
expect(metadata.getAll()).toEqual({
|
77
|
+
'dc:creator': '',
|
78
|
+
'dc:description': '',
|
79
|
+
'dc:format': 'application/pdf',
|
80
|
+
'dc:subject': '',
|
81
|
+
'dc:title': '',
|
82
|
+
'pdf:keywords': '',
|
83
|
+
'pdf:pdfversion': '1.7',
|
84
|
+
'pdf:producer': 'PDFKit.NET 4.0.102.0',
|
85
|
+
'xap:createdate': '2018-12-27T13:50:36-08:00',
|
86
|
+
'xap:creatortool': '',
|
87
|
+
'xap:metadatadate': '2018-12-27T13:50:38-08:00',
|
88
|
+
'xap:modifydate': '2018-12-27T13:50:38-08:00'
|
89
|
+
});
|
90
|
+
});
|
91
|
+
it('should correctly handle metadata containing "&apos" (issue 10407)', function () {
|
92
|
+
var data = '<x:xmpmeta xmlns:x=\'adobe:ns:meta/\'>' + '<rdf:RDF xmlns:rdf=\'http://www.w3.org/1999/02/22-rdf-syntax-ns#\'>' + '<rdf:Description xmlns:dc=\'http://purl.org/dc/elements/1.1/\'>' + '<dc:title><rdf:Alt>' + '<rdf:li xml:lang="x-default">'Foo bar baz'</rdf:li>' + '</rdf:Alt></dc:title></rdf:Description></rdf:RDF></x:xmpmeta>';
|
93
|
+
var metadata = new _metadata.Metadata(data);
|
94
|
+
expect(metadata.has('dc:title')).toBeTruthy();
|
95
|
+
expect(metadata.has('dc:qux')).toBeFalsy();
|
96
|
+
expect(metadata.get('dc:title')).toEqual('\'Foo bar baz\'');
|
97
|
+
expect(metadata.get('dc:qux')).toEqual(null);
|
98
|
+
expect(metadata.getAll()).toEqual({
|
99
|
+
'dc:title': '\'Foo bar baz\''
|
100
|
+
});
|
101
|
+
});
|
102
|
+
it('should gracefully handle unbalanced end tags (issue 10410)', function () {
|
103
|
+
var data = '<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>' + '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">' + '<rdf:Description rdf:about="" ' + 'xmlns:pdf="http://ns.adobe.com/pdf/1.3/">' + '<pdf:Producer>Soda PDF 5</pdf:Producer></rdf:Description>' + '<rdf:Description rdf:about="" ' + 'xmlns:xap="http://ns.adobe.com/xap/1.0/">' + '<xap:CreateDate>2018-10-02T08:14:49-05:00</xap:CreateDate>' + '<xap:CreatorTool>Soda PDF 5</xap:CreatorTool>' + '<xap:MetadataDate>2018-10-02T08:14:49-05:00</xap:MetadataDate> ' + '<xap:ModifyDate>2018-10-02T08:14:49-05:00</xap:ModifyDate>' + '</rdf:Description><rdf:Description rdf:about="" ' + 'xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/">' + '<xmpMM:DocumentID>uuid:00000000-1c84-3cf9-89ba-bef0e729c831' + '</xmpMM:DocumentID></rdf:Description>' + '</rdf:RDF></x:xmpmeta><?xpacket end="w"?>';
|
104
|
+
var metadata = new _metadata.Metadata(data);
|
105
|
+
expect((0, _util.isEmptyObj)(metadata.getAll())).toEqual(true);
|
106
|
+
});
|
107
|
+
it('should not be vulnerable to the billion laughs attack', function () {
|
108
|
+
var data = '<?xml version="1.0"?>' + '<!DOCTYPE lolz [' + ' <!ENTITY lol "lol">' + ' <!ENTITY lol1 "&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;">' + ' <!ENTITY lol2 "&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;">' + ' <!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;">' + ' <!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;">' + ' <!ENTITY lol5 "&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;">' + ' <!ENTITY lol6 "&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;">' + ' <!ENTITY lol7 "&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;">' + ' <!ENTITY lol8 "&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;">' + ' <!ENTITY lol9 "&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;">' + ']>' + '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">' + ' <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1/">' + ' <dc:title>' + ' <rdf:Alt>' + ' <rdf:li xml:lang="x-default">a&lol9;b</rdf:li>' + ' </rdf:Alt>' + ' </dc:title>' + ' </rdf:Description>' + '</rdf:RDF>';
|
109
|
+
var metadata = new _metadata.Metadata(data);
|
110
|
+
expect(metadata.has('dc:title')).toBeTruthy();
|
111
|
+
expect(metadata.has('dc:qux')).toBeFalsy();
|
112
|
+
expect(metadata.get('dc:title')).toEqual('a&lol9;b');
|
113
|
+
expect(metadata.get('dc:qux')).toEqual(null);
|
114
|
+
expect(metadata.getAll()).toEqual({
|
115
|
+
'dc:title': 'a&lol9;b'
|
116
|
+
});
|
117
|
+
});
|
58
118
|
});
|
@@ -2,7 +2,7 @@
|
|
2
2
|
* @licstart The following is the entire license notice for the
|
3
3
|
* Javascript code in this page
|
4
4
|
*
|
5
|
-
* Copyright
|
5
|
+
* Copyright 2019 Mozilla Foundation
|
6
6
|
*
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
8
|
* you may not use this file except in compliance with the License.
|
@@ -19,9 +19,9 @@
|
|
19
19
|
* @licend The above is the entire license notice for the
|
20
20
|
* Javascript code in this page
|
21
21
|
*/
|
22
|
-
|
22
|
+
"use strict";
|
23
23
|
|
24
|
-
var _murmurhash = require(
|
24
|
+
var _murmurhash = require("../../core/murmurhash3");
|
25
25
|
|
26
26
|
describe('MurmurHash3_64', function () {
|
27
27
|
it('instantiates without seed', function () {
|
@@ -2,7 +2,7 @@
|
|
2
2
|
* @licstart The following is the entire license notice for the
|
3
3
|
* Javascript code in this page
|
4
4
|
*
|
5
|
-
* Copyright
|
5
|
+
* Copyright 2019 Mozilla Foundation
|
6
6
|
*
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
8
|
* you may not use this file except in compliance with the License.
|
@@ -19,15 +19,15 @@
|
|
19
19
|
* @licend The above is the entire license notice for the
|
20
20
|
* Javascript code in this page
|
21
21
|
*/
|
22
|
-
|
22
|
+
"use strict";
|
23
23
|
|
24
|
-
var
|
24
|
+
var _util = require("../../shared/util");
|
25
|
+
|
26
|
+
var _network = require("../../display/network");
|
25
27
|
|
26
28
|
describe('network', function () {
|
27
29
|
var pdf1 = new URL('../pdfs/tracemonkey.pdf', window.location).href;
|
28
30
|
var pdf1Length = 1016315;
|
29
|
-
var pdf2 = new URL('../pdfs/pdf.pdf', window.location).href;
|
30
|
-
var pdf2Length = 32472771;
|
31
31
|
it('read without stream and range', function (done) {
|
32
32
|
var stream = new _network.PDFNetworkStream({
|
33
33
|
url: pdf1,
|
@@ -43,16 +43,19 @@ describe('network', function () {
|
|
43
43
|
});
|
44
44
|
var len = 0,
|
45
45
|
count = 0;
|
46
|
+
|
46
47
|
var read = function read() {
|
47
48
|
return fullReader.read().then(function (result) {
|
48
49
|
if (result.done) {
|
49
|
-
return;
|
50
|
+
return undefined;
|
50
51
|
}
|
52
|
+
|
51
53
|
count++;
|
52
54
|
len += result.value.byteLength;
|
53
55
|
return read();
|
54
56
|
});
|
55
57
|
};
|
58
|
+
|
56
59
|
var readPromise = Promise.all([read(), promise]);
|
57
60
|
readPromise.then(function (page) {
|
58
61
|
expect(len).toEqual(pdf1Length);
|
@@ -60,50 +63,7 @@ describe('network', function () {
|
|
60
63
|
expect(isStreamingSupported).toEqual(false);
|
61
64
|
expect(isRangeSupported).toEqual(false);
|
62
65
|
done();
|
63
|
-
})
|
64
|
-
done.fail(reason);
|
65
|
-
});
|
66
|
-
});
|
67
|
-
it('read with streaming', function (done) {
|
68
|
-
var userAgent = window.navigator.userAgent;
|
69
|
-
var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(userAgent);
|
70
|
-
if (!m || m[1] < 9) {
|
71
|
-
expect(true).toEqual(true);
|
72
|
-
done();
|
73
|
-
return;
|
74
|
-
}
|
75
|
-
var stream = new _network.PDFNetworkStream({
|
76
|
-
url: pdf2,
|
77
|
-
rangeChunkSize: 65536,
|
78
|
-
disableStream: false,
|
79
|
-
disableRange: false
|
80
|
-
});
|
81
|
-
var fullReader = stream.getFullReader();
|
82
|
-
var isStreamingSupported, isRangeSupported;
|
83
|
-
var promise = fullReader.headersReady.then(function () {
|
84
|
-
isStreamingSupported = fullReader.isStreamingSupported;
|
85
|
-
isRangeSupported = fullReader.isRangeSupported;
|
86
|
-
});
|
87
|
-
var len = 0,
|
88
|
-
count = 0;
|
89
|
-
var read = function read() {
|
90
|
-
return fullReader.read().then(function (result) {
|
91
|
-
if (result.done) {
|
92
|
-
return;
|
93
|
-
}
|
94
|
-
count++;
|
95
|
-
len += result.value.byteLength;
|
96
|
-
return read();
|
97
|
-
});
|
98
|
-
};
|
99
|
-
var readPromise = Promise.all([read(), promise]);
|
100
|
-
readPromise.then(function () {
|
101
|
-
expect(len).toEqual(pdf2Length);
|
102
|
-
expect(count).toBeGreaterThan(1);
|
103
|
-
expect(isStreamingSupported).toEqual(true);
|
104
|
-
expect(isRangeSupported).toEqual(true);
|
105
|
-
done();
|
106
|
-
}).catch(function (reason) {
|
66
|
+
})["catch"](function (reason) {
|
107
67
|
done.fail(reason);
|
108
68
|
});
|
109
69
|
});
|
@@ -121,23 +81,30 @@ describe('network', function () {
|
|
121
81
|
var promise = fullReader.headersReady.then(function () {
|
122
82
|
isStreamingSupported = fullReader.isStreamingSupported;
|
123
83
|
isRangeSupported = fullReader.isRangeSupported;
|
124
|
-
fullReader.cancel('Don\'t need
|
84
|
+
fullReader.cancel(new _util.AbortException('Don\'t need fullReader.'));
|
125
85
|
fullReaderCancelled = true;
|
126
86
|
});
|
127
87
|
var tailSize = pdf1Length % rangeSize || rangeSize;
|
128
88
|
var range1Reader = stream.getRangeReader(pdf1Length - tailSize - rangeSize, pdf1Length - tailSize);
|
129
89
|
var range2Reader = stream.getRangeReader(pdf1Length - tailSize, pdf1Length);
|
130
|
-
var result1 = {
|
131
|
-
|
90
|
+
var result1 = {
|
91
|
+
value: 0
|
92
|
+
},
|
93
|
+
result2 = {
|
94
|
+
value: 0
|
95
|
+
};
|
96
|
+
|
132
97
|
var read = function read(reader, lenResult) {
|
133
98
|
return reader.read().then(function (result) {
|
134
99
|
if (result.done) {
|
135
|
-
return;
|
100
|
+
return undefined;
|
136
101
|
}
|
102
|
+
|
137
103
|
lenResult.value += result.value.byteLength;
|
138
104
|
return read(reader, lenResult);
|
139
105
|
});
|
140
106
|
};
|
107
|
+
|
141
108
|
var readPromises = Promise.all([read(range1Reader, result1), read(range2Reader, result2), promise]);
|
142
109
|
readPromises.then(function () {
|
143
110
|
expect(result1.value).toEqual(rangeSize);
|
@@ -146,7 +113,7 @@ describe('network', function () {
|
|
146
113
|
expect(isRangeSupported).toEqual(true);
|
147
114
|
expect(fullReaderCancelled).toEqual(true);
|
148
115
|
done();
|
149
|
-
})
|
116
|
+
})["catch"](function (reason) {
|
150
117
|
done.fail(reason);
|
151
118
|
});
|
152
119
|
});
|