mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Remove some, with Prettier 2.3.0
, unnecessary // prettier-ignore
comments
To get the maximum benefit from something like Prettier, you obviously don't want to disable the automatic formatting unless absolutely necessary. When we added Prettier there were a number of cases, mostly involving larger Arrays, which required disabling of the automatic formatting for overall readability and/or to not break inline comments. With changes in Prettier version `2.3.0`, see [the release notes](https://prettier.io/blog/2021/05/09/2.3.0.html#concise-formatting-of-number-only-arrays-10106httpsgithubcomprettierprettierpull10106-10160httpsgithubcomprettierprettierpull10160-by-thorn0httpsgithubcomthorn0), there's now better formatting support for Arrays containing only numbers. Hence we can now remove a number of `// prettier-ignore` comments, and thus get the benefit of automatic formatting in (slightly) more of the code-base.
This commit is contained in:
parent
faf6b10939
commit
1a8d05fdcf
12 changed files with 212 additions and 270 deletions
|
@ -123,10 +123,9 @@ describe("CFFParser", function () {
|
|||
"ignores reserved commands in parseDict, and refuses to add privateDict " +
|
||||
"keys with invalid values (bug 1308536)",
|
||||
function () {
|
||||
// prettier-ignore
|
||||
const bytes = new Uint8Array([
|
||||
64, 39, 31, 30, 252, 114, 137, 115, 79, 30, 197, 119, 2, 99, 127, 6
|
||||
]);
|
||||
64, 39, 31, 30, 252, 114, 137, 115, 79, 30, 197, 119, 2, 99, 127, 6,
|
||||
]);
|
||||
parser.bytes = bytes;
|
||||
const topDict = cff.topDict;
|
||||
topDict.setByName("Private", [bytes.length, 0]);
|
||||
|
|
|
@ -355,16 +355,13 @@ describe("crypto", function () {
|
|||
it("should correctly check a user key", function () {
|
||||
const alg = new PDF17();
|
||||
const password = new Uint8Array([117, 115, 101, 114]);
|
||||
// prettier-ignore
|
||||
const userValidation = new Uint8Array([
|
||||
117, 169, 4, 32, 159, 101, 22, 220
|
||||
117, 169, 4, 32, 159, 101, 22, 220,
|
||||
]);
|
||||
// prettier-ignore
|
||||
const userPassword = new Uint8Array([
|
||||
131, 242, 143, 160, 87, 2, 138, 134, 79,
|
||||
253, 189, 173, 224, 73, 144, 241, 190, 81,
|
||||
197, 15, 249, 105, 145, 151, 15, 194, 65,
|
||||
3, 1, 126, 187, 221
|
||||
131, 242, 143, 160, 87, 2, 138, 134, 79, 253, 189, 173, 224, 73, 144,
|
||||
241, 190, 81, 197, 15, 249, 105, 145, 151, 15, 194, 65, 3, 1, 126, 187,
|
||||
221,
|
||||
]);
|
||||
const result = alg.checkUserPassword(
|
||||
password,
|
||||
|
@ -377,24 +374,19 @@ describe("crypto", function () {
|
|||
it("should correctly check an owner key", function () {
|
||||
const alg = new PDF17();
|
||||
const password = new Uint8Array([111, 119, 110, 101, 114]);
|
||||
// prettier-ignore
|
||||
const ownerValidation = new Uint8Array([
|
||||
243, 118, 71, 153, 128, 17, 101, 62
|
||||
243, 118, 71, 153, 128, 17, 101, 62,
|
||||
]);
|
||||
// prettier-ignore
|
||||
const ownerPassword = new Uint8Array([
|
||||
60, 98, 137, 35, 51, 101, 200, 152, 210,
|
||||
178, 226, 228, 134, 205, 163, 24, 204,
|
||||
126, 177, 36, 106, 50, 36, 125, 210, 172,
|
||||
171, 120, 222, 108, 139, 115
|
||||
60, 98, 137, 35, 51, 101, 200, 152, 210, 178, 226, 228, 134, 205, 163,
|
||||
24, 204, 126, 177, 36, 106, 50, 36, 125, 210, 172, 171, 120, 222, 108,
|
||||
139, 115,
|
||||
]);
|
||||
// prettier-ignore
|
||||
const uBytes = new Uint8Array([
|
||||
131, 242, 143, 160, 87, 2, 138, 134, 79, 253,
|
||||
189, 173, 224, 73, 144, 241, 190, 81, 197, 15,
|
||||
249, 105, 145, 151, 15, 194, 65, 3, 1, 126, 187,
|
||||
221, 117, 169, 4, 32, 159, 101, 22, 220, 168,
|
||||
94, 215, 192, 100, 38, 188, 40
|
||||
131, 242, 143, 160, 87, 2, 138, 134, 79, 253, 189, 173, 224, 73, 144,
|
||||
241, 190, 81, 197, 15, 249, 105, 145, 151, 15, 194, 65, 3, 1, 126, 187,
|
||||
221, 117, 169, 4, 32, 159, 101, 22, 220, 168, 94, 215, 192, 100, 38,
|
||||
188, 40,
|
||||
]);
|
||||
const result = alg.checkOwnerPassword(
|
||||
password,
|
||||
|
@ -409,20 +401,15 @@ describe("crypto", function () {
|
|||
const alg = new PDF17();
|
||||
const password = new Uint8Array([117, 115, 101, 114]);
|
||||
const userKeySalt = new Uint8Array([168, 94, 215, 192, 100, 38, 188, 40]);
|
||||
// prettier-ignore
|
||||
const userEncryption = new Uint8Array([
|
||||
35, 150, 195, 169, 245, 51, 51, 255,
|
||||
158, 158, 33, 242, 231, 75, 125, 190,
|
||||
25, 126, 172, 114, 195, 244, 137, 245,
|
||||
234, 165, 42, 74, 60, 38, 17, 17
|
||||
35, 150, 195, 169, 245, 51, 51, 255, 158, 158, 33, 242, 231, 75, 125,
|
||||
190, 25, 126, 172, 114, 195, 244, 137, 245, 234, 165, 42, 74, 60, 38,
|
||||
17, 17,
|
||||
]);
|
||||
const result = alg.getUserKey(password, userKeySalt, userEncryption);
|
||||
// prettier-ignore
|
||||
const expected = new Uint8Array([
|
||||
63, 114, 136, 209, 87, 61, 12, 30, 249, 1,
|
||||
186, 144, 254, 248, 163, 153, 151, 51, 133,
|
||||
10, 80, 152, 206, 15, 72, 187, 231, 33, 224,
|
||||
239, 13, 213
|
||||
63, 114, 136, 209, 87, 61, 12, 30, 249, 1, 186, 144, 254, 248, 163, 153,
|
||||
151, 51, 133, 10, 80, 152, 206, 15, 72, 187, 231, 33, 224, 239, 13, 213,
|
||||
]);
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
|
@ -430,24 +417,18 @@ describe("crypto", function () {
|
|||
it("should generate a file encryption key from the owner key", function () {
|
||||
const alg = new PDF17();
|
||||
const password = new Uint8Array([111, 119, 110, 101, 114]);
|
||||
// prettier-ignore
|
||||
const ownerKeySalt = new Uint8Array([
|
||||
200, 245, 242, 12, 218, 123, 24, 120
|
||||
200, 245, 242, 12, 218, 123, 24, 120,
|
||||
]);
|
||||
// prettier-ignore
|
||||
const ownerEncryption = new Uint8Array([
|
||||
213, 202, 14, 189, 110, 76, 70, 191, 6,
|
||||
195, 10, 190, 157, 100, 144, 85, 8, 62,
|
||||
123, 178, 156, 229, 50, 40, 229, 216,
|
||||
54, 222, 34, 38, 106, 223
|
||||
213, 202, 14, 189, 110, 76, 70, 191, 6, 195, 10, 190, 157, 100, 144, 85,
|
||||
8, 62, 123, 178, 156, 229, 50, 40, 229, 216, 54, 222, 34, 38, 106, 223,
|
||||
]);
|
||||
// prettier-ignore
|
||||
const uBytes = new Uint8Array([
|
||||
131, 242, 143, 160, 87, 2, 138, 134, 79, 253,
|
||||
189, 173, 224, 73, 144, 241, 190, 81, 197, 15,
|
||||
249, 105, 145, 151, 15, 194, 65, 3, 1, 126, 187,
|
||||
221, 117, 169, 4, 32, 159, 101, 22, 220, 168,
|
||||
94, 215, 192, 100, 38, 188, 40
|
||||
131, 242, 143, 160, 87, 2, 138, 134, 79, 253, 189, 173, 224, 73, 144,
|
||||
241, 190, 81, 197, 15, 249, 105, 145, 151, 15, 194, 65, 3, 1, 126, 187,
|
||||
221, 117, 169, 4, 32, 159, 101, 22, 220, 168, 94, 215, 192, 100, 38,
|
||||
188, 40,
|
||||
]);
|
||||
const result = alg.getOwnerKey(
|
||||
password,
|
||||
|
@ -455,12 +436,9 @@ describe("crypto", function () {
|
|||
uBytes,
|
||||
ownerEncryption
|
||||
);
|
||||
// prettier-ignore
|
||||
const expected = new Uint8Array([
|
||||
63, 114, 136, 209, 87, 61, 12, 30, 249, 1,
|
||||
186, 144, 254, 248, 163, 153, 151, 51, 133,
|
||||
10, 80, 152, 206, 15, 72, 187, 231, 33, 224,
|
||||
239, 13, 213
|
||||
63, 114, 136, 209, 87, 61, 12, 30, 249, 1, 186, 144, 254, 248, 163, 153,
|
||||
151, 51, 133, 10, 80, 152, 206, 15, 72, 187, 231, 33, 224, 239, 13, 213,
|
||||
]);
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
|
@ -470,16 +448,13 @@ describe("crypto", function () {
|
|||
it("should correctly check a user key", function () {
|
||||
const alg = new PDF20();
|
||||
const password = new Uint8Array([117, 115, 101, 114]);
|
||||
// prettier-ignore
|
||||
const userValidation = new Uint8Array([
|
||||
83, 245, 146, 101, 198, 247, 34, 198
|
||||
83, 245, 146, 101, 198, 247, 34, 198,
|
||||
]);
|
||||
// prettier-ignore
|
||||
const userPassword = new Uint8Array([
|
||||
94, 230, 205, 75, 166, 99, 250, 76, 219,
|
||||
128, 17, 85, 57, 17, 33, 164, 150, 46,
|
||||
103, 176, 160, 156, 187, 233, 166, 223,
|
||||
163, 253, 147, 235, 95, 184
|
||||
94, 230, 205, 75, 166, 99, 250, 76, 219, 128, 17, 85, 57, 17, 33, 164,
|
||||
150, 46, 103, 176, 160, 156, 187, 233, 166, 223, 163, 253, 147, 235, 95,
|
||||
184,
|
||||
]);
|
||||
const result = alg.checkUserPassword(
|
||||
password,
|
||||
|
@ -492,24 +467,18 @@ describe("crypto", function () {
|
|||
it("should correctly check an owner key", function () {
|
||||
const alg = new PDF20();
|
||||
const password = new Uint8Array([111, 119, 110, 101, 114]);
|
||||
// prettier-ignore
|
||||
const ownerValidation = new Uint8Array([
|
||||
142, 232, 169, 208, 202, 214, 5, 185
|
||||
142, 232, 169, 208, 202, 214, 5, 185,
|
||||
]);
|
||||
// prettier-ignore
|
||||
const ownerPassword = new Uint8Array([
|
||||
88, 232, 62, 54, 245, 26, 245, 209, 137,
|
||||
123, 221, 72, 199, 49, 37, 217, 31, 74,
|
||||
115, 167, 127, 158, 176, 77, 45, 163, 87,
|
||||
47, 39, 90, 217, 141
|
||||
88, 232, 62, 54, 245, 26, 245, 209, 137, 123, 221, 72, 199, 49, 37, 217,
|
||||
31, 74, 115, 167, 127, 158, 176, 77, 45, 163, 87, 47, 39, 90, 217, 141,
|
||||
]);
|
||||
// prettier-ignore
|
||||
const uBytes = new Uint8Array([
|
||||
94, 230, 205, 75, 166, 99, 250, 76, 219, 128,
|
||||
17, 85, 57, 17, 33, 164, 150, 46, 103, 176, 160,
|
||||
156, 187, 233, 166, 223, 163, 253, 147, 235, 95,
|
||||
184, 83, 245, 146, 101, 198, 247, 34, 198, 191,
|
||||
11, 16, 94, 237, 216, 20, 175
|
||||
94, 230, 205, 75, 166, 99, 250, 76, 219, 128, 17, 85, 57, 17, 33, 164,
|
||||
150, 46, 103, 176, 160, 156, 187, 233, 166, 223, 163, 253, 147, 235, 95,
|
||||
184, 83, 245, 146, 101, 198, 247, 34, 198, 191, 11, 16, 94, 237, 216,
|
||||
20, 175,
|
||||
]);
|
||||
const result = alg.checkOwnerPassword(
|
||||
password,
|
||||
|
@ -524,20 +493,15 @@ describe("crypto", function () {
|
|||
const alg = new PDF20();
|
||||
const password = new Uint8Array([117, 115, 101, 114]);
|
||||
const userKeySalt = new Uint8Array([191, 11, 16, 94, 237, 216, 20, 175]);
|
||||
// prettier-ignore
|
||||
const userEncryption = new Uint8Array([
|
||||
121, 208, 2, 181, 230, 89, 156, 60, 253,
|
||||
143, 212, 28, 84, 180, 196, 177, 173,
|
||||
128, 221, 107, 46, 20, 94, 186, 135, 51,
|
||||
95, 24, 20, 223, 254, 36
|
||||
121, 208, 2, 181, 230, 89, 156, 60, 253, 143, 212, 28, 84, 180, 196,
|
||||
177, 173, 128, 221, 107, 46, 20, 94, 186, 135, 51, 95, 24, 20, 223, 254,
|
||||
36,
|
||||
]);
|
||||
const result = alg.getUserKey(password, userKeySalt, userEncryption);
|
||||
// prettier-ignore
|
||||
const expected = new Uint8Array([
|
||||
42, 218, 213, 39, 73, 91, 72, 79, 67, 38, 248,
|
||||
133, 18, 189, 61, 34, 107, 79, 29, 56, 59,
|
||||
181, 213, 118, 113, 34, 65, 210, 87, 174, 22,
|
||||
239
|
||||
42, 218, 213, 39, 73, 91, 72, 79, 67, 38, 248, 133, 18, 189, 61, 34,
|
||||
107, 79, 29, 56, 59, 181, 213, 118, 113, 34, 65, 210, 87, 174, 22, 239,
|
||||
]);
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
|
@ -546,20 +510,16 @@ describe("crypto", function () {
|
|||
const alg = new PDF20();
|
||||
const password = new Uint8Array([111, 119, 110, 101, 114]);
|
||||
const ownerKeySalt = new Uint8Array([29, 208, 185, 46, 11, 76, 135, 149]);
|
||||
// prettier-ignore
|
||||
const ownerEncryption = new Uint8Array([
|
||||
209, 73, 224, 77, 103, 155, 201, 181,
|
||||
190, 68, 223, 20, 62, 90, 56, 210, 5,
|
||||
240, 178, 128, 238, 124, 68, 254, 253,
|
||||
244, 62, 108, 208, 135, 10, 251
|
||||
209, 73, 224, 77, 103, 155, 201, 181, 190, 68, 223, 20, 62, 90, 56, 210,
|
||||
5, 240, 178, 128, 238, 124, 68, 254, 253, 244, 62, 108, 208, 135, 10,
|
||||
251,
|
||||
]);
|
||||
// prettier-ignore
|
||||
const uBytes = new Uint8Array([
|
||||
94, 230, 205, 75, 166, 99, 250, 76, 219, 128,
|
||||
17, 85, 57, 17, 33, 164, 150, 46, 103, 176, 160,
|
||||
156, 187, 233, 166, 223, 163, 253, 147, 235, 95,
|
||||
184, 83, 245, 146, 101, 198, 247, 34, 198, 191,
|
||||
11, 16, 94, 237, 216, 20, 175
|
||||
94, 230, 205, 75, 166, 99, 250, 76, 219, 128, 17, 85, 57, 17, 33, 164,
|
||||
150, 46, 103, 176, 160, 156, 187, 233, 166, 223, 163, 253, 147, 235, 95,
|
||||
184, 83, 245, 146, 101, 198, 247, 34, 198, 191, 11, 16, 94, 237, 216,
|
||||
20, 175,
|
||||
]);
|
||||
const result = alg.getOwnerKey(
|
||||
password,
|
||||
|
@ -567,12 +527,9 @@ describe("crypto", function () {
|
|||
uBytes,
|
||||
ownerEncryption
|
||||
);
|
||||
// prettier-ignore
|
||||
const expected = new Uint8Array([
|
||||
42, 218, 213, 39, 73, 91, 72, 79, 67, 38, 248,
|
||||
133, 18, 189, 61, 34, 107, 79, 29, 56, 59,
|
||||
181, 213, 118, 113, 34, 65, 210, 87, 174, 22,
|
||||
239
|
||||
42, 218, 213, 39, 73, 91, 72, 79, 67, 38, 248, 133, 18, 189, 61, 34,
|
||||
107, 79, 29, 56, 59, 181, 213, 118, 113, 34, 65, 210, 87, 174, 22, 239,
|
||||
]);
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue