@email-utils/validator-syntax 0.0.1-8 → 1.0.0-rc.1

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.
@@ -0,0 +1,2112 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _email_utils_validator_syntax = require("./index.cjs");
3
+ //#region src/fixtures/types.ts
4
+ const presets = [
5
+ "practical",
6
+ "rfc5321",
7
+ "rfc5322",
8
+ "html5"
9
+ ];
10
+ /** The support matrix's rows, in order, with each feature's label. */
11
+ const syntaxFeatures = [
12
+ {
13
+ feature: "dot-atom",
14
+ label: "Letters, digits, and single dots"
15
+ },
16
+ {
17
+ feature: "atext-specials",
18
+ label: "Printable specials like `+`, `/`, `=`, and `_`"
19
+ },
20
+ {
21
+ feature: "route-chars",
22
+ label: "Route characters (`%`, `!`)"
23
+ },
24
+ {
25
+ feature: "misplaced-dots",
26
+ label: "Leading, trailing, or consecutive dots"
27
+ },
28
+ {
29
+ feature: "long-local",
30
+ label: "Local part over 64 characters"
31
+ },
32
+ {
33
+ feature: "quoted-local",
34
+ label: "Quoted local part"
35
+ },
36
+ {
37
+ feature: "quoted-pair",
38
+ label: "Backslash escapes in a quoted string"
39
+ },
40
+ {
41
+ feature: "obs-local",
42
+ label: "Dot-separated atoms and quoted strings mixed"
43
+ },
44
+ {
45
+ feature: "comments",
46
+ label: "Comments"
47
+ },
48
+ {
49
+ feature: "fws",
50
+ label: "Whitespace and line folding between tokens"
51
+ },
52
+ {
53
+ feature: "obs-control",
54
+ label: "Control characters (obsolete syntax)"
55
+ },
56
+ {
57
+ feature: "ipv4-literal",
58
+ label: "IPv4 address literal"
59
+ },
60
+ {
61
+ feature: "ipv6-literal",
62
+ label: "IPv6 address literal"
63
+ },
64
+ {
65
+ feature: "general-literal",
66
+ label: "Other domain literals"
67
+ },
68
+ {
69
+ feature: "dotless-domain",
70
+ label: "Domain with no dot"
71
+ },
72
+ {
73
+ feature: "unknown-tld",
74
+ label: "TLD outside the IANA set"
75
+ }
76
+ ];
77
+ const valid = { ok: true };
78
+ function fail(reason, index) {
79
+ return index === void 0 ? {
80
+ ok: false,
81
+ reason
82
+ } : {
83
+ ok: false,
84
+ reason,
85
+ index
86
+ };
87
+ }
88
+ /** The same result under every preset. */
89
+ function everywhere(expected) {
90
+ return {
91
+ practical: expected,
92
+ rfc5321: expected,
93
+ rfc5322: expected,
94
+ html5: expected
95
+ };
96
+ }
97
+ /** Valid under both RFC presets; `practical` and `html5` both give `rejected`. */
98
+ function rfcOnly(rejected) {
99
+ return {
100
+ practical: rejected,
101
+ rfc5321: valid,
102
+ rfc5322: valid,
103
+ html5: rejected
104
+ };
105
+ }
106
+ /** Fails the same way under every preset but rfc5322, which gives `rfc5322`. */
107
+ function allBut5322(others, rfc5322) {
108
+ return {
109
+ ...everywhere(others),
110
+ rfc5322
111
+ };
112
+ }
113
+ /** Valid only under `rfc5322`; every other preset gives `rejected`. */
114
+ function rfc5322Only(rejected) {
115
+ return {
116
+ ...everywhere(rejected),
117
+ rfc5322: valid
118
+ };
119
+ }
120
+ //#endregion
121
+ //#region src/fixtures/isemail.ts
122
+ /** A domain literal that only rfc5322's dtext accepts. */
123
+ const rfc5322Literal = {
124
+ practical: fail("syntax.domain.invalid_char", 5),
125
+ rfc5321: fail("syntax.domain.literal_invalid", 5),
126
+ rfc5322: valid,
127
+ html5: fail("syntax.domain.invalid_char", 5)
128
+ };
129
+ /** Quote-unaware presets fail at the opening quote; the RFC presets give `rfc`. */
130
+ function quotedLocal(rfc) {
131
+ return {
132
+ practical: fail("syntax.local.invalid_char", 0),
133
+ rfc5321: rfc,
134
+ rfc5322: rfc,
135
+ html5: fail("syntax.local.invalid_char", 0)
136
+ };
137
+ }
138
+ const longLabel = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghikl";
139
+ const isemailFixtures = [
140
+ {
141
+ isemail: 1,
142
+ address: "",
143
+ description: "Empty string",
144
+ expected: everywhere(fail("syntax.address.empty"))
145
+ },
146
+ {
147
+ isemail: 2,
148
+ address: "test",
149
+ description: "No @",
150
+ expected: everywhere(fail("syntax.address.no_at"))
151
+ },
152
+ {
153
+ isemail: 3,
154
+ address: "@",
155
+ description: "Only an @",
156
+ expected: everywhere(fail("syntax.local.empty"))
157
+ },
158
+ {
159
+ isemail: 4,
160
+ address: "test@",
161
+ description: "Nothing after the @",
162
+ expected: everywhere(fail("syntax.domain.empty"))
163
+ },
164
+ {
165
+ isemail: 5,
166
+ address: "test@io",
167
+ description: "Domain with no dot, a real TLD",
168
+ feature: "dotless-domain",
169
+ expected: {
170
+ ...everywhere(fail("syntax.domain.no_dot")),
171
+ html5: valid
172
+ }
173
+ },
174
+ {
175
+ isemail: 6,
176
+ address: "@io",
177
+ description: "Nothing before the @, dotless domain",
178
+ expected: everywhere(fail("syntax.local.empty"))
179
+ },
180
+ {
181
+ isemail: 7,
182
+ address: "@iana.org",
183
+ description: "Nothing before the @",
184
+ expected: everywhere(fail("syntax.local.empty"))
185
+ },
186
+ {
187
+ isemail: 8,
188
+ address: "test@iana.org",
189
+ description: "Simple address",
190
+ feature: "dot-atom",
191
+ expected: everywhere(valid)
192
+ },
193
+ {
194
+ isemail: 9,
195
+ address: "test@nominet.org.uk",
196
+ description: "Three-label domain",
197
+ feature: "dot-atom",
198
+ expected: everywhere(valid)
199
+ },
200
+ {
201
+ isemail: 10,
202
+ address: "test@about.museum",
203
+ description: "Six-letter TLD",
204
+ feature: "dot-atom",
205
+ expected: everywhere(valid)
206
+ },
207
+ {
208
+ isemail: 11,
209
+ address: "a@iana.org",
210
+ description: "Single-letter local part",
211
+ feature: "dot-atom",
212
+ expected: everywhere(valid)
213
+ },
214
+ {
215
+ isemail: 12,
216
+ address: "test@e.com",
217
+ description: "Single-letter domain label",
218
+ feature: "dot-atom",
219
+ expected: everywhere(valid)
220
+ },
221
+ {
222
+ isemail: 13,
223
+ address: "test@iana.a",
224
+ description: "Single-letter TLD",
225
+ feature: "unknown-tld",
226
+ expected: {
227
+ ...everywhere(valid),
228
+ practical: fail("syntax.tld.unknown")
229
+ }
230
+ },
231
+ {
232
+ isemail: 14,
233
+ address: "test.test@iana.org",
234
+ description: "Dot in the local part",
235
+ feature: "dot-atom",
236
+ expected: everywhere(valid)
237
+ },
238
+ {
239
+ isemail: 15,
240
+ address: ".test@iana.org",
241
+ description: "Local part starting with a dot",
242
+ feature: "misplaced-dots",
243
+ expected: {
244
+ ...everywhere(fail("syntax.local.invalid_char", 0)),
245
+ html5: valid
246
+ }
247
+ },
248
+ {
249
+ isemail: 16,
250
+ address: "test.@iana.org",
251
+ description: "Local part ending with a dot",
252
+ feature: "misplaced-dots",
253
+ expected: {
254
+ ...everywhere(fail("syntax.local.invalid_char", 4)),
255
+ html5: valid
256
+ }
257
+ },
258
+ {
259
+ isemail: 17,
260
+ address: "test..iana.org",
261
+ description: "No @, consecutive dots",
262
+ expected: everywhere(fail("syntax.address.no_at"))
263
+ },
264
+ {
265
+ isemail: 18,
266
+ address: "test_exa-mple.com",
267
+ description: "No @, underscore and hyphen",
268
+ expected: everywhere(fail("syntax.address.no_at"))
269
+ },
270
+ {
271
+ isemail: 19,
272
+ address: "!#$%&`*+/=?^`{|}~@iana.org",
273
+ description: "Local part of printable specials only",
274
+ feature: "route-chars",
275
+ expected: {
276
+ ...everywhere(valid),
277
+ practical: fail("syntax.local.invalid_char", 0)
278
+ }
279
+ },
280
+ {
281
+ isemail: 20,
282
+ address: "test\\@test@iana.org",
283
+ description: "Backslash-escaped @ outside a quoted string",
284
+ expected: everywhere(fail("syntax.local.invalid_char", 4))
285
+ },
286
+ {
287
+ isemail: 21,
288
+ address: "123@iana.org",
289
+ description: "All-digit local part",
290
+ feature: "dot-atom",
291
+ expected: everywhere(valid)
292
+ },
293
+ {
294
+ isemail: 22,
295
+ address: "test@123.com",
296
+ description: "All-digit domain label",
297
+ feature: "dot-atom",
298
+ expected: everywhere(valid)
299
+ },
300
+ {
301
+ isemail: 23,
302
+ address: "test@iana.123",
303
+ description: "All-digit TLD",
304
+ feature: "unknown-tld",
305
+ expected: {
306
+ ...everywhere(valid),
307
+ practical: fail("syntax.tld.unknown")
308
+ }
309
+ },
310
+ {
311
+ isemail: 24,
312
+ address: "test@255.255.255.255",
313
+ description: "Dotted quad without brackets",
314
+ feature: "unknown-tld",
315
+ expected: {
316
+ ...everywhere(valid),
317
+ practical: fail("syntax.tld.unknown")
318
+ }
319
+ },
320
+ {
321
+ isemail: 25,
322
+ address: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghiklm@iana.org",
323
+ description: "Local part of exactly 64 characters",
324
+ feature: "dot-atom",
325
+ expected: everywhere(valid)
326
+ },
327
+ {
328
+ isemail: 26,
329
+ address: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghiklmn@iana.org",
330
+ description: "Local part of 65 characters",
331
+ feature: "long-local",
332
+ expected: {
333
+ practical: fail("syntax.local.too_long"),
334
+ rfc5321: fail("syntax.local.too_long"),
335
+ rfc5322: valid,
336
+ html5: valid
337
+ }
338
+ },
339
+ {
340
+ isemail: 27,
341
+ address: `test@${longLabel}.com`,
342
+ description: "Domain label of exactly 63 characters",
343
+ feature: "dot-atom",
344
+ expected: everywhere(valid)
345
+ },
346
+ {
347
+ isemail: 28,
348
+ address: `test@${longLabel}m.com`,
349
+ description: "Domain label of 64 characters",
350
+ expected: everywhere(fail("syntax.domain.label_invalid", 5))
351
+ },
352
+ {
353
+ isemail: 29,
354
+ address: "test@mason-dixon.com",
355
+ description: "Hyphen inside a domain label",
356
+ feature: "dot-atom",
357
+ expected: everywhere(valid)
358
+ },
359
+ {
360
+ isemail: 30,
361
+ address: "test@-iana.org",
362
+ description: "Domain label starting with a hyphen",
363
+ expected: everywhere(fail("syntax.domain.label_invalid", 5))
364
+ },
365
+ {
366
+ isemail: 31,
367
+ address: "test@iana-.com",
368
+ description: "Domain label ending with a hyphen",
369
+ expected: everywhere(fail("syntax.domain.label_invalid", 9))
370
+ },
371
+ {
372
+ isemail: 32,
373
+ address: "test@c--n.com",
374
+ description: "Consecutive hyphens inside a domain label",
375
+ feature: "dot-atom",
376
+ expected: everywhere(valid)
377
+ },
378
+ {
379
+ isemail: 33,
380
+ address: "test@iana.co-uk",
381
+ description: "Hyphenated TLD",
382
+ feature: "unknown-tld",
383
+ expected: {
384
+ ...everywhere(valid),
385
+ practical: fail("syntax.tld.unknown")
386
+ }
387
+ },
388
+ {
389
+ isemail: 34,
390
+ address: "test@.iana.org",
391
+ description: "Domain starting with a dot",
392
+ expected: everywhere(fail("syntax.domain.label_invalid", 5))
393
+ },
394
+ {
395
+ isemail: 35,
396
+ address: "test@iana.org.",
397
+ description: "Domain ending with a dot",
398
+ expected: everywhere(fail("syntax.domain.label_invalid", 13))
399
+ },
400
+ {
401
+ isemail: 36,
402
+ address: "test@iana..com",
403
+ description: "Consecutive dots in the domain",
404
+ expected: everywhere(fail("syntax.domain.label_invalid", 10))
405
+ },
406
+ {
407
+ isemail: 37,
408
+ address: "a@a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v",
409
+ description: "126 single-letter domain labels",
410
+ expected: {
411
+ ...everywhere(valid),
412
+ practical: fail("syntax.tld.unknown")
413
+ }
414
+ },
415
+ {
416
+ isemail: 38,
417
+ address: `abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghiklm@${longLabel}.${longLabel}.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi`,
418
+ description: "Address of exactly 254 characters",
419
+ expected: {
420
+ ...everywhere(valid),
421
+ practical: fail("syntax.tld.unknown")
422
+ }
423
+ },
424
+ {
425
+ isemail: 39,
426
+ address: `abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghiklm@${longLabel}.${longLabel}.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghij`,
427
+ description: "Address of 255 characters",
428
+ expected: everywhere(fail("syntax.address.too_long"))
429
+ },
430
+ {
431
+ isemail: 40,
432
+ address: `a@${longLabel}.${longLabel}.${longLabel}.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefg.hij`,
433
+ description: "Domain of 255 characters",
434
+ expected: {
435
+ ...everywhere(fail("syntax.domain.too_long")),
436
+ html5: fail("syntax.address.too_long")
437
+ }
438
+ },
439
+ {
440
+ isemail: 41,
441
+ address: `a@${longLabel}.${longLabel}.${longLabel}.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefg.hijk`,
442
+ description: "Domain of 256 characters",
443
+ expected: {
444
+ ...everywhere(fail("syntax.domain.too_long")),
445
+ html5: fail("syntax.address.too_long")
446
+ }
447
+ },
448
+ {
449
+ isemail: 42,
450
+ address: "\"test\"@iana.org",
451
+ description: "Quoted local part",
452
+ feature: "quoted-local",
453
+ expected: rfcOnly(fail("syntax.local.invalid_char", 0))
454
+ },
455
+ {
456
+ isemail: 43,
457
+ address: "\"\"@iana.org",
458
+ description: "Empty quoted local part",
459
+ feature: "quoted-local",
460
+ expected: rfcOnly(fail("syntax.local.invalid_char", 0))
461
+ },
462
+ {
463
+ isemail: 44,
464
+ address: "\"\"\"@iana.org",
465
+ description: "Stray quote after an empty quoted string",
466
+ expected: quotedLocal(fail("syntax.local.invalid_char", 2))
467
+ },
468
+ {
469
+ isemail: 45,
470
+ address: "\"\\a\"@iana.org",
471
+ description: "Escaped letter in a quoted string",
472
+ feature: "quoted-pair",
473
+ expected: rfcOnly(fail("syntax.local.invalid_char", 0))
474
+ },
475
+ {
476
+ isemail: 46,
477
+ address: "\"\\\"\"@iana.org",
478
+ description: "Escaped quote in a quoted string",
479
+ feature: "quoted-pair",
480
+ expected: rfcOnly(fail("syntax.local.invalid_char", 0))
481
+ },
482
+ {
483
+ isemail: 47,
484
+ address: "\"\\\"@iana.org",
485
+ description: "Quoted string whose closing quote is escaped",
486
+ expected: quotedLocal(fail("syntax.address.no_at"))
487
+ },
488
+ {
489
+ isemail: 48,
490
+ address: "\"\\\\\"@iana.org",
491
+ description: "Escaped backslash in a quoted string",
492
+ feature: "quoted-pair",
493
+ expected: rfcOnly(fail("syntax.local.invalid_char", 0))
494
+ },
495
+ {
496
+ isemail: 49,
497
+ address: "test\"@iana.org",
498
+ description: "Stray quote at the end of an atom",
499
+ expected: everywhere(fail("syntax.local.invalid_char", 4))
500
+ },
501
+ {
502
+ isemail: 50,
503
+ address: "\"test@iana.org",
504
+ description: "Unterminated quoted string",
505
+ expected: quotedLocal(fail("syntax.address.no_at"))
506
+ },
507
+ {
508
+ isemail: 51,
509
+ address: "\"test\"test@iana.org",
510
+ description: "Atom straight after a quoted string",
511
+ expected: quotedLocal(fail("syntax.local.invalid_char", 6))
512
+ },
513
+ {
514
+ isemail: 52,
515
+ address: "test\"text\"@iana.org",
516
+ description: "Quoted string straight after an atom",
517
+ expected: everywhere(fail("syntax.local.invalid_char", 4))
518
+ },
519
+ {
520
+ isemail: 53,
521
+ address: "\"test\"\"test\"@iana.org",
522
+ description: "Two quoted strings with no dot between",
523
+ expected: quotedLocal(fail("syntax.local.invalid_char", 6))
524
+ },
525
+ {
526
+ isemail: 54,
527
+ address: "\"test\".\"test\"@iana.org",
528
+ description: "Dot-separated quoted strings",
529
+ feature: "obs-local",
530
+ expected: {
531
+ ...quotedLocal(valid),
532
+ rfc5321: fail("syntax.local.invalid_char", 6)
533
+ }
534
+ },
535
+ {
536
+ isemail: 55,
537
+ address: "\"test\\ test\"@iana.org",
538
+ description: "Escaped space in a quoted string",
539
+ feature: "quoted-pair",
540
+ expected: rfcOnly(fail("syntax.local.invalid_char", 0))
541
+ },
542
+ {
543
+ isemail: 56,
544
+ address: "\"test\".test@iana.org",
545
+ description: "Quoted string then a dot-separated atom",
546
+ feature: "obs-local",
547
+ expected: {
548
+ ...quotedLocal(valid),
549
+ rfc5321: fail("syntax.local.invalid_char", 6)
550
+ }
551
+ },
552
+ {
553
+ isemail: 57,
554
+ address: "\"test\0\"@iana.org",
555
+ description: "NUL in a quoted string",
556
+ expected: quotedLocal(fail("syntax.local.invalid_char", 5))
557
+ },
558
+ {
559
+ isemail: 58,
560
+ address: "\"test\\\0\"@iana.org",
561
+ description: "Escaped NUL in a quoted string",
562
+ feature: "obs-control",
563
+ expected: {
564
+ ...quotedLocal(valid),
565
+ rfc5321: fail("syntax.local.invalid_char", 6)
566
+ }
567
+ },
568
+ {
569
+ isemail: 59,
570
+ address: "\"abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefghj\"@iana.org",
571
+ description: "Quoted local part of 65 characters",
572
+ expected: {
573
+ ...quotedLocal(valid),
574
+ rfc5321: fail("syntax.local.too_long")
575
+ }
576
+ },
577
+ {
578
+ isemail: 60,
579
+ address: "\"abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz abcdefg\\h\"@iana.org",
580
+ description: "Quoted local part of 65 characters with an escape",
581
+ expected: {
582
+ ...quotedLocal(valid),
583
+ rfc5321: fail("syntax.local.too_long")
584
+ }
585
+ },
586
+ {
587
+ isemail: 61,
588
+ address: "test@[255.255.255.255]",
589
+ description: "IPv4 address literal",
590
+ feature: "ipv4-literal",
591
+ expected: rfcOnly(fail("syntax.domain.invalid_char", 5))
592
+ },
593
+ {
594
+ isemail: 62,
595
+ address: "test@a[255.255.255.255]",
596
+ description: "Domain literal after a label",
597
+ expected: everywhere(fail("syntax.domain.invalid_char", 6))
598
+ },
599
+ {
600
+ isemail: 63,
601
+ address: "test@[255.255.255]",
602
+ description: "IPv4 literal with three octets",
603
+ feature: "general-literal",
604
+ expected: rfc5322Literal
605
+ },
606
+ {
607
+ isemail: 64,
608
+ address: "test@[255.255.255.255.255]",
609
+ description: "IPv4 literal with five octets",
610
+ feature: "general-literal",
611
+ expected: rfc5322Literal
612
+ },
613
+ {
614
+ isemail: 65,
615
+ address: "test@[255.255.255.256]",
616
+ description: "IPv4 literal with an octet over 255",
617
+ feature: "general-literal",
618
+ expected: rfc5322Literal
619
+ },
620
+ {
621
+ isemail: 66,
622
+ address: "test@[1111:2222:3333:4444:5555:6666:7777:8888]",
623
+ description: "IPv6 literal without the IPv6 tag",
624
+ feature: "general-literal",
625
+ expected: rfc5322Literal
626
+ },
627
+ {
628
+ isemail: 67,
629
+ address: "test@[IPv6:1111:2222:3333:4444:5555:6666:7777]",
630
+ description: "IPv6 literal with seven groups",
631
+ feature: "general-literal",
632
+ expected: rfc5322Literal
633
+ },
634
+ {
635
+ isemail: 68,
636
+ address: "test@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888]",
637
+ description: "IPv6 literal with eight groups",
638
+ feature: "ipv6-literal",
639
+ expected: rfcOnly(fail("syntax.domain.invalid_char", 5))
640
+ },
641
+ {
642
+ isemail: 69,
643
+ address: "test@[IPv6:1111:2222:3333:4444:5555:6666:7777:8888:9999]",
644
+ description: "IPv6 literal with nine groups",
645
+ feature: "general-literal",
646
+ expected: rfc5322Literal
647
+ },
648
+ {
649
+ isemail: 70,
650
+ address: "test@[IPv6:1111:2222:3333:4444:5555:6666:7777:888G]",
651
+ description: "IPv6 literal with a non-hex digit",
652
+ feature: "general-literal",
653
+ expected: rfc5322Literal
654
+ },
655
+ {
656
+ isemail: 71,
657
+ address: "test@[IPv6:1111:2222:3333:4444:5555:6666::8888]",
658
+ description: "IPv6 literal with :: standing for one group",
659
+ feature: "general-literal",
660
+ expected: rfc5322Literal
661
+ },
662
+ {
663
+ isemail: 72,
664
+ address: "test@[IPv6:1111:2222:3333:4444:5555::8888]",
665
+ description: "Compressed IPv6 literal",
666
+ feature: "ipv6-literal",
667
+ expected: rfcOnly(fail("syntax.domain.invalid_char", 5))
668
+ },
669
+ {
670
+ isemail: 73,
671
+ address: "test@[IPv6:1111:2222:3333:4444:5555:6666::7777:8888]",
672
+ description: "Compressed IPv6 literal with eight groups",
673
+ feature: "general-literal",
674
+ expected: rfc5322Literal
675
+ },
676
+ {
677
+ isemail: 74,
678
+ address: "test@[IPv6::3333:4444:5555:6666:7777:8888]",
679
+ description: "IPv6 literal starting with a single colon",
680
+ feature: "general-literal",
681
+ expected: rfc5322Literal
682
+ },
683
+ {
684
+ isemail: 75,
685
+ address: "test@[IPv6:::3333:4444:5555:6666:7777:8888]",
686
+ description: "IPv6 literal starting with ::",
687
+ feature: "ipv6-literal",
688
+ expected: rfcOnly(fail("syntax.domain.invalid_char", 5))
689
+ },
690
+ {
691
+ isemail: 76,
692
+ address: "test@[IPv6:1111::4444:5555::8888]",
693
+ description: "IPv6 literal with two ::",
694
+ feature: "general-literal",
695
+ expected: rfc5322Literal
696
+ },
697
+ {
698
+ isemail: 77,
699
+ address: "test@[IPv6:::]",
700
+ description: "IPv6 unspecified address literal",
701
+ feature: "ipv6-literal",
702
+ expected: rfcOnly(fail("syntax.domain.invalid_char", 5))
703
+ },
704
+ {
705
+ isemail: 78,
706
+ address: "test@[IPv6:1111:2222:3333:4444:5555:255.255.255.255]",
707
+ description: "IPv4-in-IPv6 literal with five groups",
708
+ feature: "general-literal",
709
+ expected: rfc5322Literal
710
+ },
711
+ {
712
+ isemail: 79,
713
+ address: "test@[IPv6:1111:2222:3333:4444:5555:6666:255.255.255.255]",
714
+ description: "IPv4-in-IPv6 literal with six groups",
715
+ feature: "ipv6-literal",
716
+ expected: rfcOnly(fail("syntax.domain.invalid_char", 5))
717
+ },
718
+ {
719
+ isemail: 80,
720
+ address: "test@[IPv6:1111:2222:3333:4444:5555:6666:7777:255.255.255.255]",
721
+ description: "IPv4-in-IPv6 literal with seven groups",
722
+ feature: "general-literal",
723
+ expected: rfc5322Literal
724
+ },
725
+ {
726
+ isemail: 81,
727
+ address: "test@[IPv6:1111:2222:3333:4444::255.255.255.255]",
728
+ description: "Compressed IPv4-in-IPv6 literal",
729
+ feature: "ipv6-literal",
730
+ expected: rfcOnly(fail("syntax.domain.invalid_char", 5))
731
+ },
732
+ {
733
+ isemail: 82,
734
+ address: "test@[IPv6:1111:2222:3333:4444:5555:6666::255.255.255.255]",
735
+ description: "Compressed IPv4-in-IPv6 literal with six groups",
736
+ feature: "general-literal",
737
+ expected: rfc5322Literal
738
+ },
739
+ {
740
+ isemail: 83,
741
+ address: "test@[IPv6:1111:2222:3333:4444:::255.255.255.255]",
742
+ description: "IPv4-in-IPv6 literal with :::",
743
+ feature: "general-literal",
744
+ expected: rfc5322Literal
745
+ },
746
+ {
747
+ isemail: 84,
748
+ address: "test@[IPv6::255.255.255.255]",
749
+ description: "IPv4-in-IPv6 literal starting with a single colon",
750
+ feature: "general-literal",
751
+ expected: rfc5322Literal
752
+ },
753
+ {
754
+ isemail: 85,
755
+ address: " test @iana.org",
756
+ description: "Spaces around the local part",
757
+ feature: "fws",
758
+ expected: allBut5322(fail("syntax.local.unquoted_space", 0), valid)
759
+ },
760
+ {
761
+ isemail: 86,
762
+ address: "test@ iana .com",
763
+ description: "Spaces around a domain label",
764
+ feature: "fws",
765
+ expected: allBut5322(fail("syntax.domain.invalid_char", 5), valid)
766
+ },
767
+ {
768
+ isemail: 87,
769
+ address: "test . test@iana.org",
770
+ description: "Spaces around a dot in the local part",
771
+ feature: "fws",
772
+ expected: allBut5322(fail("syntax.local.unquoted_space", 4), valid)
773
+ },
774
+ {
775
+ isemail: 88,
776
+ address: "\r\n test@iana.org",
777
+ description: "Folded whitespace before the local part",
778
+ feature: "fws",
779
+ expected: allBut5322(fail("syntax.local.invalid_char", 0), valid)
780
+ },
781
+ {
782
+ isemail: 89,
783
+ address: "\r\n \r\n test@iana.org",
784
+ description: "Whitespace folded twice before the local part",
785
+ feature: "fws",
786
+ expected: allBut5322(fail("syntax.local.invalid_char", 0), valid)
787
+ },
788
+ {
789
+ isemail: 90,
790
+ address: "(comment)test@iana.org",
791
+ description: "Comment before the local part",
792
+ feature: "comments",
793
+ expected: rfc5322Only(fail("syntax.comment.not_allowed", 0))
794
+ },
795
+ {
796
+ isemail: 91,
797
+ address: "((comment)test@iana.org",
798
+ description: "Unterminated comment around a nested one",
799
+ expected: allBut5322(fail("syntax.comment.not_allowed", 0), fail("syntax.address.no_at"))
800
+ },
801
+ {
802
+ isemail: 92,
803
+ address: "(comment(comment))test@iana.org",
804
+ description: "Nested comment",
805
+ feature: "comments",
806
+ expected: rfc5322Only(fail("syntax.comment.not_allowed", 0))
807
+ },
808
+ {
809
+ isemail: 93,
810
+ address: "test@(comment)iana.org",
811
+ description: "Comment before the domain",
812
+ feature: "comments",
813
+ expected: rfc5322Only(fail("syntax.comment.not_allowed", 5))
814
+ },
815
+ {
816
+ isemail: 94,
817
+ address: "test(comment)test@iana.org",
818
+ description: "Comment between two atoms with no dot",
819
+ expected: allBut5322(fail("syntax.comment.not_allowed", 4), fail("syntax.local.invalid_char", 13))
820
+ },
821
+ {
822
+ isemail: 95,
823
+ address: "test@(comment)[255.255.255.255]",
824
+ description: "Comment before a domain literal",
825
+ feature: "comments",
826
+ expected: rfc5322Only(fail("syntax.comment.not_allowed", 5))
827
+ },
828
+ {
829
+ isemail: 96,
830
+ address: "(comment)abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghiklm@iana.org",
831
+ description: "Comment before a 64-character local part",
832
+ feature: "comments",
833
+ expected: rfc5322Only(fail("syntax.comment.not_allowed", 0))
834
+ },
835
+ {
836
+ isemail: 97,
837
+ address: `test@(comment)${longLabel}.com`,
838
+ description: "Comment before a 63-character domain label",
839
+ feature: "comments",
840
+ expected: rfc5322Only(fail("syntax.comment.not_allowed", 5))
841
+ },
842
+ {
843
+ isemail: 98,
844
+ address: "(comment)test@abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghik.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghik.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk.abcdefghijklmnopqrstuvwxyzabcdefghijk.abcdefghijklmnopqrstu",
845
+ description: "Comment before a 254-character address",
846
+ feature: "comments",
847
+ expected: rfc5322Only(fail("syntax.comment.not_allowed", 0))
848
+ },
849
+ {
850
+ isemail: 99,
851
+ address: "test@iana.org\n",
852
+ description: "Trailing line feed",
853
+ expected: everywhere(fail("syntax.domain.invalid_char", 13))
854
+ },
855
+ {
856
+ isemail: 100,
857
+ address: "test@xn--hxajbheg2az3al.xn--jxalpdlp",
858
+ description: "Punycode domain with a retired test TLD",
859
+ feature: "unknown-tld",
860
+ expected: {
861
+ ...everywhere(valid),
862
+ practical: fail("syntax.tld.unknown")
863
+ }
864
+ },
865
+ {
866
+ isemail: 101,
867
+ address: "xn--test@iana.org",
868
+ description: "Punycode prefix in the local part",
869
+ feature: "dot-atom",
870
+ expected: everywhere(valid)
871
+ },
872
+ {
873
+ isemail: 102,
874
+ address: "test@iana.org-",
875
+ description: "TLD ending with a hyphen",
876
+ expected: everywhere(fail("syntax.domain.label_invalid", 13))
877
+ },
878
+ {
879
+ isemail: 104,
880
+ address: "(test@iana.org",
881
+ description: "Unterminated comment before the @",
882
+ expected: allBut5322(fail("syntax.comment.not_allowed", 0), fail("syntax.address.no_at"))
883
+ },
884
+ {
885
+ isemail: 105,
886
+ address: "test@(iana.org",
887
+ description: "Unterminated comment in the domain",
888
+ expected: allBut5322(fail("syntax.comment.not_allowed", 5), fail("syntax.comment.unterminated", 5))
889
+ },
890
+ {
891
+ isemail: 106,
892
+ address: "test@[1.2.3.4",
893
+ description: "Unterminated domain literal",
894
+ expected: {
895
+ practical: fail("syntax.domain.invalid_char", 5),
896
+ rfc5321: fail("syntax.domain.literal_invalid", 5),
897
+ rfc5322: fail("syntax.domain.literal_invalid", 5),
898
+ html5: fail("syntax.domain.invalid_char", 5)
899
+ }
900
+ },
901
+ {
902
+ isemail: 107,
903
+ address: "\"test\\\"@iana.org",
904
+ description: "Quoted string whose closing quote is escaped",
905
+ expected: quotedLocal(fail("syntax.address.no_at"))
906
+ },
907
+ {
908
+ isemail: 108,
909
+ address: "(comment\\)test@iana.org",
910
+ description: "Comment whose closing parenthesis is escaped",
911
+ expected: allBut5322(fail("syntax.comment.not_allowed", 0), fail("syntax.address.no_at"))
912
+ },
913
+ {
914
+ isemail: 109,
915
+ address: "test@iana.org(comment\\)",
916
+ description: "Trailing comment whose closing parenthesis is escaped",
917
+ expected: allBut5322(fail("syntax.comment.not_allowed", 13), fail("syntax.comment.unterminated", 13))
918
+ },
919
+ {
920
+ isemail: 110,
921
+ address: "test@iana.org(comment\\",
922
+ description: "Trailing comment ending in a backslash",
923
+ expected: allBut5322(fail("syntax.comment.not_allowed", 13), fail("syntax.comment.unterminated", 13))
924
+ },
925
+ {
926
+ isemail: 112,
927
+ address: "test@[RFC-5322-domain-literal]",
928
+ description: "Domain literal that isn't an address",
929
+ feature: "general-literal",
930
+ expected: rfc5322Literal
931
+ },
932
+ {
933
+ isemail: 113,
934
+ address: "test@[RFC-5322]-domain-literal]",
935
+ description: "Text after a domain literal",
936
+ expected: {
937
+ ...rfc5322Literal,
938
+ rfc5322: fail("syntax.domain.invalid_char", 15)
939
+ }
940
+ },
941
+ {
942
+ isemail: 114,
943
+ address: "test@[RFC-5322-[domain-literal]",
944
+ description: "Unescaped [ inside a domain literal",
945
+ expected: {
946
+ ...rfc5322Literal,
947
+ rfc5322: fail("syntax.domain.literal_invalid", 5)
948
+ }
949
+ },
950
+ {
951
+ isemail: 115,
952
+ address: "test@[RFC-5322-\\\x07-domain-literal]",
953
+ description: "Escaped BEL in a domain literal",
954
+ feature: "obs-control",
955
+ expected: rfc5322Literal
956
+ },
957
+ {
958
+ isemail: 116,
959
+ address: "test@[RFC-5322-\\ -domain-literal]",
960
+ description: "Escaped tab in a domain literal",
961
+ feature: "general-literal",
962
+ expected: rfc5322Literal
963
+ },
964
+ {
965
+ isemail: 117,
966
+ address: "test@[RFC-5322-\\]-domain-literal]",
967
+ description: "Escaped ] in a domain literal",
968
+ feature: "general-literal",
969
+ expected: rfc5322Literal
970
+ },
971
+ {
972
+ isemail: 118,
973
+ address: "test@[RFC-5322-domain-literal\\]",
974
+ description: "Domain literal whose closing bracket is escaped",
975
+ expected: {
976
+ ...rfc5322Literal,
977
+ rfc5322: fail("syntax.domain.literal_invalid", 5)
978
+ }
979
+ },
980
+ {
981
+ isemail: 119,
982
+ address: "test@[RFC-5322-domain-literal\\",
983
+ description: "Domain literal ending in a backslash",
984
+ expected: {
985
+ ...rfc5322Literal,
986
+ rfc5322: fail("syntax.domain.literal_invalid", 5)
987
+ }
988
+ },
989
+ {
990
+ isemail: 120,
991
+ address: "test@[RFC 5322 domain literal]",
992
+ description: "Spaces in a domain literal",
993
+ feature: "general-literal",
994
+ expected: rfc5322Literal
995
+ },
996
+ {
997
+ isemail: 121,
998
+ address: "test@[RFC-5322-domain-literal] (comment)",
999
+ description: "Comment after a domain literal",
1000
+ expected: rfc5322Literal
1001
+ },
1002
+ {
1003
+ isemail: 123,
1004
+ address: "test@.org",
1005
+ description: "Domain starting with a dot before the TLD",
1006
+ expected: everywhere(fail("syntax.domain.label_invalid", 5))
1007
+ },
1008
+ {
1009
+ isemail: 124,
1010
+ address: "\"\"@iana.org",
1011
+ description: "DEL in a quoted string",
1012
+ feature: "obs-control",
1013
+ expected: {
1014
+ ...quotedLocal(valid),
1015
+ rfc5321: fail("syntax.local.invalid_char", 1)
1016
+ }
1017
+ },
1018
+ {
1019
+ isemail: 125,
1020
+ address: "\"\\\"@iana.org",
1021
+ description: "Escaped DEL in a quoted string",
1022
+ feature: "obs-control",
1023
+ expected: {
1024
+ ...quotedLocal(valid),
1025
+ rfc5321: fail("syntax.local.invalid_char", 2)
1026
+ }
1027
+ },
1028
+ {
1029
+ isemail: 126,
1030
+ address: "()test@iana.org",
1031
+ description: "DEL in a comment",
1032
+ feature: "obs-control",
1033
+ expected: rfc5322Only(fail("syntax.comment.not_allowed", 0))
1034
+ },
1035
+ {
1036
+ isemail: 127,
1037
+ address: "test@iana.org\r",
1038
+ description: "Trailing CR",
1039
+ expected: everywhere(fail("syntax.domain.invalid_char", 13))
1040
+ },
1041
+ {
1042
+ isemail: 128,
1043
+ address: "\rtest@iana.org",
1044
+ description: "Leading CR",
1045
+ expected: everywhere(fail("syntax.local.invalid_char", 0))
1046
+ },
1047
+ {
1048
+ isemail: 129,
1049
+ address: "\"\rtest\"@iana.org",
1050
+ description: "CR in a quoted string",
1051
+ expected: quotedLocal(fail("syntax.local.invalid_char", 1))
1052
+ },
1053
+ {
1054
+ isemail: 130,
1055
+ address: "(\r)test@iana.org",
1056
+ description: "CR in a comment",
1057
+ expected: allBut5322(fail("syntax.comment.not_allowed", 0), fail("syntax.local.invalid_char", 1))
1058
+ },
1059
+ {
1060
+ isemail: 131,
1061
+ address: "test@iana.org(\r)",
1062
+ description: "CR in a trailing comment",
1063
+ expected: allBut5322(fail("syntax.comment.not_allowed", 13), fail("syntax.domain.invalid_char", 14))
1064
+ },
1065
+ {
1066
+ isemail: 132,
1067
+ address: "\ntest@iana.org",
1068
+ description: "Leading LF",
1069
+ expected: everywhere(fail("syntax.local.invalid_char", 0))
1070
+ },
1071
+ {
1072
+ isemail: 133,
1073
+ address: "\"\n\"@iana.org",
1074
+ description: "LF in a quoted string",
1075
+ expected: quotedLocal(fail("syntax.local.invalid_char", 1))
1076
+ },
1077
+ {
1078
+ isemail: 134,
1079
+ address: "\"\\\n\"@iana.org",
1080
+ description: "Escaped LF in a quoted string",
1081
+ feature: "obs-control",
1082
+ expected: {
1083
+ ...quotedLocal(valid),
1084
+ rfc5321: fail("syntax.local.invalid_char", 2)
1085
+ }
1086
+ },
1087
+ {
1088
+ isemail: 135,
1089
+ address: "(\n)test@iana.org",
1090
+ description: "LF in a comment",
1091
+ expected: allBut5322(fail("syntax.comment.not_allowed", 0), fail("syntax.local.invalid_char", 1))
1092
+ },
1093
+ {
1094
+ isemail: 136,
1095
+ address: "\x07@iana.org",
1096
+ description: "BEL as the local part",
1097
+ expected: everywhere(fail("syntax.local.invalid_char", 0))
1098
+ },
1099
+ {
1100
+ isemail: 137,
1101
+ address: "test@\x07.org",
1102
+ description: "BEL as a domain label",
1103
+ expected: everywhere(fail("syntax.domain.invalid_char", 5))
1104
+ },
1105
+ {
1106
+ isemail: 138,
1107
+ address: "\"\x07\"@iana.org",
1108
+ description: "BEL in a quoted string",
1109
+ feature: "obs-control",
1110
+ expected: {
1111
+ ...quotedLocal(valid),
1112
+ rfc5321: fail("syntax.local.invalid_char", 1)
1113
+ }
1114
+ },
1115
+ {
1116
+ isemail: 139,
1117
+ address: "\"\\\x07\"@iana.org",
1118
+ description: "Escaped BEL in a quoted string",
1119
+ feature: "obs-control",
1120
+ expected: {
1121
+ ...quotedLocal(valid),
1122
+ rfc5321: fail("syntax.local.invalid_char", 2)
1123
+ }
1124
+ },
1125
+ {
1126
+ isemail: 140,
1127
+ address: "(\x07)test@iana.org",
1128
+ description: "BEL in a comment",
1129
+ feature: "obs-control",
1130
+ expected: rfc5322Only(fail("syntax.comment.not_allowed", 0))
1131
+ },
1132
+ {
1133
+ isemail: 141,
1134
+ address: "\r\ntest@iana.org",
1135
+ description: "Leading CRLF with no whitespace after it",
1136
+ expected: everywhere(fail("syntax.local.invalid_char", 0))
1137
+ },
1138
+ {
1139
+ isemail: 142,
1140
+ address: "\r\n \r\ntest@iana.org",
1141
+ description: "Folded whitespace ending in a CRLF",
1142
+ expected: allBut5322(fail("syntax.local.invalid_char", 0), fail("syntax.local.invalid_char", 3))
1143
+ },
1144
+ {
1145
+ isemail: 143,
1146
+ address: " \r\ntest@iana.org",
1147
+ description: "Space then a CRLF with no whitespace after it",
1148
+ expected: allBut5322(fail("syntax.local.unquoted_space", 0), fail("syntax.local.invalid_char", 1))
1149
+ },
1150
+ {
1151
+ isemail: 144,
1152
+ address: " \r\n test@iana.org",
1153
+ description: "Folded whitespace before the local part, starting with a space",
1154
+ feature: "fws",
1155
+ expected: allBut5322(fail("syntax.local.unquoted_space", 0), valid)
1156
+ },
1157
+ {
1158
+ isemail: 145,
1159
+ address: " \r\n \r\ntest@iana.org",
1160
+ description: "Folded whitespace ending in a CRLF, starting with a space",
1161
+ expected: allBut5322(fail("syntax.local.unquoted_space", 0), fail("syntax.local.invalid_char", 4))
1162
+ },
1163
+ {
1164
+ isemail: 146,
1165
+ address: " \r\n\r\ntest@iana.org",
1166
+ description: "Two CRLFs in a row",
1167
+ expected: allBut5322(fail("syntax.local.unquoted_space", 0), fail("syntax.local.invalid_char", 1))
1168
+ },
1169
+ {
1170
+ isemail: 147,
1171
+ address: " \r\n\r\n test@iana.org",
1172
+ description: "Two CRLFs in a row, then a space",
1173
+ expected: allBut5322(fail("syntax.local.unquoted_space", 0), fail("syntax.local.invalid_char", 1))
1174
+ },
1175
+ {
1176
+ isemail: 148,
1177
+ address: "test@iana.org\r\n ",
1178
+ description: "Folded whitespace after the domain",
1179
+ feature: "fws",
1180
+ expected: allBut5322(fail("syntax.domain.invalid_char", 13), valid)
1181
+ },
1182
+ {
1183
+ isemail: 149,
1184
+ address: "test@iana.org\r\n \r\n ",
1185
+ description: "Whitespace folded twice after the domain",
1186
+ feature: "fws",
1187
+ expected: allBut5322(fail("syntax.domain.invalid_char", 13), valid)
1188
+ },
1189
+ {
1190
+ isemail: 150,
1191
+ address: "test@iana.org\r\n",
1192
+ description: "Trailing CRLF",
1193
+ expected: everywhere(fail("syntax.domain.invalid_char", 13))
1194
+ },
1195
+ {
1196
+ isemail: 151,
1197
+ address: "test@iana.org\r\n \r\n",
1198
+ description: "Folded whitespace after the domain, ending in a CRLF",
1199
+ expected: allBut5322(fail("syntax.domain.invalid_char", 13), fail("syntax.domain.invalid_char", 16))
1200
+ },
1201
+ {
1202
+ isemail: 152,
1203
+ address: "test@iana.org \r\n",
1204
+ description: "Trailing space then a CRLF",
1205
+ expected: allBut5322(fail("syntax.domain.invalid_char", 13), fail("syntax.domain.invalid_char", 14))
1206
+ },
1207
+ {
1208
+ isemail: 153,
1209
+ address: "test@iana.org \r\n ",
1210
+ description: "Folded whitespace after the domain, starting with a space",
1211
+ feature: "fws",
1212
+ expected: allBut5322(fail("syntax.domain.invalid_char", 13), valid)
1213
+ },
1214
+ {
1215
+ isemail: 154,
1216
+ address: "test@iana.org \r\n \r\n",
1217
+ description: "Folded whitespace after the domain, starting with a space and ending in a CRLF",
1218
+ expected: allBut5322(fail("syntax.domain.invalid_char", 13), fail("syntax.domain.invalid_char", 17))
1219
+ },
1220
+ {
1221
+ isemail: 155,
1222
+ address: "test@iana.org \r\n\r\n",
1223
+ description: "Trailing space then two CRLFs",
1224
+ expected: allBut5322(fail("syntax.domain.invalid_char", 13), fail("syntax.domain.invalid_char", 14))
1225
+ },
1226
+ {
1227
+ isemail: 156,
1228
+ address: "test@iana.org \r\n\r\n ",
1229
+ description: "Trailing space then two CRLFs and a space",
1230
+ expected: allBut5322(fail("syntax.domain.invalid_char", 13), fail("syntax.domain.invalid_char", 14))
1231
+ },
1232
+ {
1233
+ isemail: 157,
1234
+ address: " test@iana.org",
1235
+ description: "Leading space",
1236
+ feature: "fws",
1237
+ expected: allBut5322(fail("syntax.local.unquoted_space", 0), valid)
1238
+ },
1239
+ {
1240
+ isemail: 158,
1241
+ address: "test@iana.org ",
1242
+ description: "Trailing space",
1243
+ feature: "fws",
1244
+ expected: allBut5322(fail("syntax.domain.invalid_char", 13), valid)
1245
+ },
1246
+ {
1247
+ isemail: 159,
1248
+ address: "test@[IPv6:1::2:]",
1249
+ description: "IPv6 literal ending with a single colon",
1250
+ feature: "general-literal",
1251
+ expected: rfc5322Literal
1252
+ },
1253
+ {
1254
+ isemail: 160,
1255
+ address: "\"test\\©\"@iana.org",
1256
+ description: "Escaped non-ASCII character in a quoted string",
1257
+ expected: quotedLocal(fail("syntax.local.invalid_char", 6))
1258
+ },
1259
+ {
1260
+ isemail: 161,
1261
+ address: "test@iana/icann.org",
1262
+ description: "Slash in the domain",
1263
+ expected: allBut5322(fail("syntax.domain.invalid_char", 9), valid)
1264
+ },
1265
+ {
1266
+ isemail: 165,
1267
+ address: "test.(comment)test@iana.org",
1268
+ description: "Comment after a dot in the local part",
1269
+ feature: "comments",
1270
+ expected: rfc5322Only(fail("syntax.comment.not_allowed", 5))
1271
+ },
1272
+ {
1273
+ isemail: 166,
1274
+ address: "test@org",
1275
+ description: "TLD alone as the domain",
1276
+ feature: "dotless-domain",
1277
+ expected: {
1278
+ ...everywhere(fail("syntax.domain.no_dot")),
1279
+ html5: valid
1280
+ }
1281
+ },
1282
+ {
1283
+ isemail: 167,
1284
+ address: "test@test.com",
1285
+ description: "Common test domain",
1286
+ feature: "dot-atom",
1287
+ expected: everywhere(valid)
1288
+ },
1289
+ {
1290
+ isemail: 168,
1291
+ address: "test@nic.no",
1292
+ description: "Country-code TLD",
1293
+ feature: "dot-atom",
1294
+ expected: everywhere(valid)
1295
+ }
1296
+ ];
1297
+ //#endregion
1298
+ //#region src/fixtures/legacy.ts
1299
+ const quotedLocalRejected = "practical rejects quoted local parts, which are legal but never seen on real mailboxes";
1300
+ const routeRejected = "practical rejects `%` and `!`, the source-route and bang-path characters, which are legal but never seen on real mailboxes";
1301
+ /** The 0.0.1 suite reran these cases uppercased, under `local.alphaLower: false`. */
1302
+ function withUppercase(fixture) {
1303
+ return [fixture, {
1304
+ ...fixture,
1305
+ address: fixture.address.toUpperCase(),
1306
+ description: `${fixture.description}, uppercased`
1307
+ }];
1308
+ }
1309
+ const legacyFixtures = [
1310
+ ...withUppercase({
1311
+ address: "simple@example.com",
1312
+ description: "Simple address",
1313
+ feature: "dot-atom",
1314
+ expected: everywhere(valid),
1315
+ legacy: true
1316
+ }),
1317
+ ...withUppercase({
1318
+ address: "x@example.com",
1319
+ description: "Single-letter local part",
1320
+ feature: "dot-atom",
1321
+ expected: everywhere(valid),
1322
+ legacy: true
1323
+ }),
1324
+ ...withUppercase({
1325
+ address: "admin@test.co",
1326
+ description: "Two-letter TLD",
1327
+ feature: "dot-atom",
1328
+ expected: everywhere(valid),
1329
+ legacy: true
1330
+ }),
1331
+ ...withUppercase({
1332
+ address: "test@gmail.com",
1333
+ description: "Gmail address",
1334
+ feature: "dot-atom",
1335
+ expected: everywhere(valid),
1336
+ legacy: true
1337
+ }),
1338
+ ...withUppercase({
1339
+ address: "tesT@example.com",
1340
+ description: "Uppercase letter in the local part",
1341
+ feature: "dot-atom",
1342
+ expected: everywhere(valid),
1343
+ legacy: true
1344
+ }),
1345
+ ...withUppercase({
1346
+ address: "test1@example.com",
1347
+ description: "Digit in the local part",
1348
+ feature: "dot-atom",
1349
+ expected: everywhere(valid),
1350
+ legacy: true
1351
+ }),
1352
+ {
1353
+ address: "simple1@example.com",
1354
+ description: "Digit at the end of the local part",
1355
+ feature: "dot-atom",
1356
+ expected: everywhere(valid),
1357
+ legacy: true
1358
+ },
1359
+ ...withUppercase({
1360
+ address: "very.common@example.com",
1361
+ description: "Dot in the local part",
1362
+ feature: "dot-atom",
1363
+ expected: everywhere(valid),
1364
+ legacy: true
1365
+ }),
1366
+ {
1367
+ address: "disposable.style.email.with+symbol@example.com",
1368
+ description: "Dots and a plus sign in the local part",
1369
+ feature: "atext-specials",
1370
+ expected: everywhere(valid),
1371
+ legacy: true
1372
+ },
1373
+ {
1374
+ address: "other.email-with-hyphen@example.com",
1375
+ description: "Dots and hyphens in the local part",
1376
+ feature: "atext-specials",
1377
+ expected: everywhere(valid),
1378
+ legacy: true
1379
+ },
1380
+ {
1381
+ address: "user.name+tag+sorting@example.com",
1382
+ description: "Dot and plus-sign tags in the local part",
1383
+ feature: "atext-specials",
1384
+ expected: everywhere(valid),
1385
+ legacy: true
1386
+ },
1387
+ ...withUppercase({
1388
+ address: "disposablestyleemailwith+symbol@example.com",
1389
+ description: "Plus sign in the local part",
1390
+ feature: "atext-specials",
1391
+ expected: everywhere(valid),
1392
+ legacy: true
1393
+ }),
1394
+ ...withUppercase({
1395
+ address: "username+tag+sorting@example.com",
1396
+ description: "Plus-sign tags in the local part",
1397
+ feature: "atext-specials",
1398
+ expected: everywhere(valid),
1399
+ legacy: true
1400
+ }),
1401
+ ...withUppercase({
1402
+ address: "test/test@test.com",
1403
+ description: "Slash in the local part",
1404
+ feature: "atext-specials",
1405
+ expected: everywhere(valid),
1406
+ legacy: true
1407
+ }),
1408
+ ...withUppercase({
1409
+ address: "mailhost.com!username@example.org",
1410
+ description: "Bang path in the local part, dotted relay host",
1411
+ feature: "route-chars",
1412
+ expected: {
1413
+ ...everywhere(valid),
1414
+ practical: fail("syntax.local.invalid_char", 12)
1415
+ },
1416
+ legacy: true,
1417
+ flipped: routeRejected
1418
+ }),
1419
+ {
1420
+ address: "mailhost!username@example.org",
1421
+ description: "Bang path in the local part, dotless relay host",
1422
+ feature: "route-chars",
1423
+ expected: {
1424
+ ...everywhere(valid),
1425
+ practical: fail("syntax.local.invalid_char", 8)
1426
+ },
1427
+ legacy: false
1428
+ },
1429
+ ...withUppercase({
1430
+ address: "user%example.com@example.org",
1431
+ description: "Percent route in the local part, dotted relay host",
1432
+ feature: "route-chars",
1433
+ expected: {
1434
+ ...everywhere(valid),
1435
+ practical: fail("syntax.local.invalid_char", 4)
1436
+ },
1437
+ legacy: true,
1438
+ flipped: routeRejected
1439
+ }),
1440
+ {
1441
+ address: "user%example@example.org",
1442
+ description: "Percent route in the local part, dotless relay host",
1443
+ feature: "route-chars",
1444
+ expected: {
1445
+ ...everywhere(valid),
1446
+ practical: fail("syntax.local.invalid_char", 4)
1447
+ },
1448
+ legacy: false
1449
+ },
1450
+ ...withUppercase({
1451
+ address: "fully-qualified-domain@example.com",
1452
+ description: "Hyphens in the local part",
1453
+ feature: "atext-specials",
1454
+ expected: everywhere(valid),
1455
+ legacy: true
1456
+ }),
1457
+ ...withUppercase({
1458
+ address: "otheremail-with-hyphen@example.com",
1459
+ description: "Hyphens in the local part",
1460
+ feature: "atext-specials",
1461
+ expected: everywhere(valid),
1462
+ legacy: true
1463
+ }),
1464
+ ...withUppercase({
1465
+ address: "user-@example.org",
1466
+ description: "Local part ending in a hyphen",
1467
+ feature: "atext-specials",
1468
+ expected: everywhere(valid),
1469
+ legacy: true
1470
+ }),
1471
+ ...withUppercase({
1472
+ address: "exampleindeed@strange-example.com",
1473
+ description: "Hyphenated domain",
1474
+ feature: "dot-atom",
1475
+ expected: everywhere(valid),
1476
+ legacy: true
1477
+ }),
1478
+ ...withUppercase({
1479
+ address: "example-indeed@strange-example.com",
1480
+ description: "Hyphens in the local part and the domain",
1481
+ feature: "atext-specials",
1482
+ expected: everywhere(valid),
1483
+ legacy: true
1484
+ }),
1485
+ ...withUppercase({
1486
+ address: "\" \"@example.org",
1487
+ description: "Quoted space as the whole local part",
1488
+ feature: "quoted-local",
1489
+ expected: {
1490
+ practical: fail("syntax.local.invalid_char", 0),
1491
+ rfc5321: valid,
1492
+ rfc5322: valid,
1493
+ html5: fail("syntax.local.invalid_char", 0)
1494
+ },
1495
+ legacy: true,
1496
+ flipped: quotedLocalRejected
1497
+ }),
1498
+ ...withUppercase({
1499
+ address: "\"john..doe\"@example.com",
1500
+ description: "Consecutive dots inside a quoted local part",
1501
+ feature: "quoted-local",
1502
+ expected: {
1503
+ practical: fail("syntax.local.invalid_char", 0),
1504
+ rfc5321: valid,
1505
+ rfc5322: valid,
1506
+ html5: fail("syntax.local.invalid_char", 0)
1507
+ },
1508
+ legacy: true,
1509
+ flipped: quotedLocalRejected
1510
+ }),
1511
+ ...withUppercase({
1512
+ address: "\"justactually\"@example.com",
1513
+ description: "Quoted local part",
1514
+ feature: "quoted-local",
1515
+ expected: {
1516
+ practical: fail("syntax.local.invalid_char", 0),
1517
+ rfc5321: valid,
1518
+ rfc5322: valid,
1519
+ html5: fail("syntax.local.invalid_char", 0)
1520
+ },
1521
+ legacy: true,
1522
+ flipped: quotedLocalRejected
1523
+ }),
1524
+ ...withUppercase({
1525
+ address: "just.\"actually\".right@example.com",
1526
+ description: "Quoted string between dot-separated atoms",
1527
+ feature: "obs-local",
1528
+ expected: {
1529
+ practical: fail("syntax.local.invalid_char", 5),
1530
+ rfc5321: fail("syntax.local.invalid_char", 5),
1531
+ rfc5322: valid,
1532
+ html5: fail("syntax.local.invalid_char", 5)
1533
+ },
1534
+ legacy: true,
1535
+ flipped: quotedLocalRejected
1536
+ }),
1537
+ {
1538
+ address: "just.\"not\".right@example.com",
1539
+ description: "Quoted string between dot-separated atoms",
1540
+ feature: "obs-local",
1541
+ expected: {
1542
+ practical: fail("syntax.local.invalid_char", 5),
1543
+ rfc5321: fail("syntax.local.invalid_char", 5),
1544
+ rfc5322: valid,
1545
+ html5: fail("syntax.local.invalid_char", 5)
1546
+ },
1547
+ legacy: true,
1548
+ flipped: quotedLocalRejected
1549
+ },
1550
+ {
1551
+ address: "\"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual\"@strange.example.com",
1552
+ description: "Quoted strings with specials, missing their escapes",
1553
+ expected: {
1554
+ practical: fail("syntax.local.invalid_char", 0),
1555
+ rfc5321: fail("syntax.local.invalid_char", 16),
1556
+ rfc5322: fail("syntax.local.invalid_char", 31),
1557
+ html5: fail("syntax.local.invalid_char", 0)
1558
+ },
1559
+ legacy: false
1560
+ },
1561
+ ...withUppercase({
1562
+ address: "just\"not\"right@example.com",
1563
+ description: "Quotes inside an atom",
1564
+ expected: everywhere(fail("syntax.local.invalid_char", 4)),
1565
+ legacy: false
1566
+ }),
1567
+ ...withUppercase({
1568
+ address: "just.\"not\"right@example.com",
1569
+ description: "Quoted string with no dot after it",
1570
+ expected: {
1571
+ practical: fail("syntax.local.invalid_char", 5),
1572
+ rfc5321: fail("syntax.local.invalid_char", 5),
1573
+ rfc5322: fail("syntax.local.invalid_char", 10),
1574
+ html5: fail("syntax.local.invalid_char", 5)
1575
+ },
1576
+ legacy: false
1577
+ }),
1578
+ ...withUppercase({
1579
+ address: "just.\"not.\"right@example.com",
1580
+ description: "Quoted string ending in a dot, with no dot after it",
1581
+ expected: {
1582
+ practical: fail("syntax.local.invalid_char", 5),
1583
+ rfc5321: fail("syntax.local.invalid_char", 5),
1584
+ rfc5322: fail("syntax.local.invalid_char", 11),
1585
+ html5: fail("syntax.local.invalid_char", 5)
1586
+ },
1587
+ legacy: false
1588
+ }),
1589
+ ...withUppercase({
1590
+ address: "\"john..doe@example.com",
1591
+ description: "Unterminated quote",
1592
+ expected: {
1593
+ practical: fail("syntax.local.invalid_char", 0),
1594
+ rfc5321: fail("syntax.address.no_at"),
1595
+ rfc5322: fail("syntax.address.no_at"),
1596
+ html5: fail("syntax.local.invalid_char", 0)
1597
+ },
1598
+ legacy: false
1599
+ }),
1600
+ ...withUppercase({
1601
+ address: "\"john\"..doe@example.com",
1602
+ description: "Consecutive dots after a quoted string",
1603
+ expected: {
1604
+ practical: fail("syntax.local.invalid_char", 0),
1605
+ rfc5321: fail("syntax.local.invalid_char", 6),
1606
+ rfc5322: fail("syntax.local.consecutive_dots", 7),
1607
+ html5: fail("syntax.local.invalid_char", 0)
1608
+ },
1609
+ legacy: false
1610
+ }),
1611
+ ...withUppercase({
1612
+ address: "a\"b(c)d,e:f;g<h>i[j\\k]l@example.com",
1613
+ description: "Unquoted specials",
1614
+ expected: everywhere(fail("syntax.local.invalid_char", 1)),
1615
+ legacy: false
1616
+ }),
1617
+ ...withUppercase({
1618
+ address: "james richards@google.com",
1619
+ description: "Unquoted space",
1620
+ expected: everywhere(fail("syntax.local.unquoted_space", 5)),
1621
+ legacy: false
1622
+ }),
1623
+ ...withUppercase({
1624
+ address: "james\" richards@google.com",
1625
+ description: "Space after a stray quote",
1626
+ expected: everywhere(fail("syntax.local.invalid_char", 5)),
1627
+ legacy: false
1628
+ }),
1629
+ ...withUppercase({
1630
+ address: "this is\"notallowed@example.com",
1631
+ description: "Unquoted space and a stray quote",
1632
+ expected: everywhere(fail("syntax.local.unquoted_space", 4)),
1633
+ legacy: false
1634
+ }),
1635
+ ...withUppercase({
1636
+ address: "this still\"not\\allowed@example.com",
1637
+ description: "Unquoted space, a stray quote, and a backslash",
1638
+ expected: everywhere(fail("syntax.local.unquoted_space", 4)),
1639
+ legacy: false
1640
+ }),
1641
+ ...withUppercase({
1642
+ address: "john..doe@example.com",
1643
+ description: "Consecutive dots in the local part",
1644
+ feature: "misplaced-dots",
1645
+ expected: {
1646
+ practical: fail("syntax.local.consecutive_dots", 5),
1647
+ rfc5321: fail("syntax.local.consecutive_dots", 5),
1648
+ rfc5322: fail("syntax.local.consecutive_dots", 5),
1649
+ html5: valid
1650
+ },
1651
+ legacy: false
1652
+ }),
1653
+ ...withUppercase({
1654
+ address: "john.doe@example..com",
1655
+ description: "Consecutive dots in the domain",
1656
+ expected: everywhere(fail("syntax.domain.label_invalid", 17)),
1657
+ legacy: false
1658
+ }),
1659
+ ...withUppercase({
1660
+ address: "Abc.example.com",
1661
+ description: "No @",
1662
+ expected: everywhere(fail("syntax.address.no_at")),
1663
+ legacy: false
1664
+ }),
1665
+ {
1666
+ address: "Abc+example.com",
1667
+ description: "No @",
1668
+ expected: everywhere(fail("syntax.address.no_at")),
1669
+ legacy: false
1670
+ },
1671
+ ...withUppercase({
1672
+ address: "@Abc.example.com",
1673
+ description: "Nothing before the @",
1674
+ expected: everywhere(fail("syntax.local.empty")),
1675
+ legacy: false
1676
+ }),
1677
+ ...withUppercase({
1678
+ address: "A@b@c@example.com",
1679
+ description: "More than one @",
1680
+ expected: everywhere(fail("syntax.local.invalid_char", 1)),
1681
+ legacy: false
1682
+ }),
1683
+ ...withUppercase({
1684
+ address: "QA☕CHOCOLATE☕@test.com",
1685
+ description: "Non-ASCII characters in the local part",
1686
+ expected: everywhere(fail("syntax.local.invalid_char", 2)),
1687
+ legacy: false
1688
+ }),
1689
+ ...withUppercase({
1690
+ address: "i_like_underscore@but_its_not_allowed_in_this_part.example.com",
1691
+ description: "Underscores in the domain",
1692
+ expected: allBut5322(fail("syntax.domain.invalid_char", 21), valid),
1693
+ legacy: false
1694
+ }),
1695
+ ...withUppercase({
1696
+ address: "james@cb$.com",
1697
+ description: "Dollar sign in the domain",
1698
+ expected: allBut5322(fail("syntax.domain.invalid_char", 8), valid),
1699
+ legacy: false
1700
+ }),
1701
+ ...withUppercase({
1702
+ address: "1234567890123456789012345678901234567890123456789012345678901234+x@example.com",
1703
+ description: "Local part over 64 characters",
1704
+ feature: "long-local",
1705
+ expected: {
1706
+ practical: fail("syntax.local.too_long"),
1707
+ rfc5321: fail("syntax.local.too_long"),
1708
+ rfc5322: valid,
1709
+ html5: valid
1710
+ },
1711
+ legacy: false
1712
+ }),
1713
+ {
1714
+ address: "uayuYfBgRktoqVPCAJLhkcyVHFsZygReesttpNWTTiETtbQFfDUMZjyCdeaEhcotf+x@example.com",
1715
+ description: "Local part over 64 characters, letters only",
1716
+ feature: "long-local",
1717
+ expected: {
1718
+ practical: fail("syntax.local.too_long"),
1719
+ rfc5321: fail("syntax.local.too_long"),
1720
+ rfc5322: valid,
1721
+ html5: valid
1722
+ },
1723
+ legacy: false
1724
+ },
1725
+ ...withUppercase({
1726
+ address: "james@google",
1727
+ description: "Domain with no dot",
1728
+ feature: "dotless-domain",
1729
+ expected: {
1730
+ practical: fail("syntax.domain.no_dot"),
1731
+ rfc5321: fail("syntax.domain.no_dot"),
1732
+ rfc5322: fail("syntax.domain.no_dot"),
1733
+ html5: valid
1734
+ },
1735
+ legacy: false
1736
+ }),
1737
+ {
1738
+ address: "admin@mailserver1",
1739
+ description: "Domain with no dot, ending in a digit",
1740
+ feature: "dotless-domain",
1741
+ expected: {
1742
+ practical: fail("syntax.domain.no_dot"),
1743
+ rfc5321: fail("syntax.domain.no_dot"),
1744
+ rfc5322: fail("syntax.domain.no_dot"),
1745
+ html5: valid
1746
+ },
1747
+ legacy: false
1748
+ },
1749
+ {
1750
+ address: "james@g.com",
1751
+ description: "Single-character domain label",
1752
+ feature: "dot-atom",
1753
+ expected: everywhere(valid),
1754
+ legacy: false,
1755
+ flipped: "0.0.1 required two characters before the last dot (`charsBeforeDot`), rejecting real single-letter domains (validator-syntax#12)"
1756
+ },
1757
+ {
1758
+ address: "james@google.c",
1759
+ description: "Single-character TLD",
1760
+ feature: "unknown-tld",
1761
+ expected: {
1762
+ practical: fail("syntax.tld.unknown"),
1763
+ rfc5321: valid,
1764
+ rfc5322: valid,
1765
+ html5: valid
1766
+ },
1767
+ legacy: false
1768
+ },
1769
+ {
1770
+ address: "test@example.thisisnotavalidtld",
1771
+ description: "TLD outside the IANA set",
1772
+ feature: "unknown-tld",
1773
+ expected: {
1774
+ practical: fail("syntax.tld.unknown"),
1775
+ rfc5321: valid,
1776
+ rfc5322: valid,
1777
+ html5: valid
1778
+ },
1779
+ legacy: false
1780
+ }
1781
+ ];
1782
+ //#endregion
1783
+ //#region src/fixtures/rfc3696.ts
1784
+ const rfc3696Fixtures = [
1785
+ {
1786
+ address: "Abc\\@def@example.com",
1787
+ description: "Backslash-escaped @ outside a quoted string",
1788
+ expected: everywhere(fail("syntax.local.invalid_char", 3))
1789
+ },
1790
+ {
1791
+ address: "Fred\\ Bloggs@example.com",
1792
+ description: "Backslash-escaped space outside a quoted string",
1793
+ expected: everywhere(fail("syntax.local.invalid_char", 4))
1794
+ },
1795
+ {
1796
+ address: "Joe.\\\\Blow@example.com",
1797
+ description: "Backslash-escaped backslash outside a quoted string",
1798
+ expected: everywhere(fail("syntax.local.invalid_char", 4))
1799
+ },
1800
+ {
1801
+ address: "\"Abc\\@def\"@example.com",
1802
+ description: "Escaped @ in a quoted string",
1803
+ feature: "quoted-pair",
1804
+ expected: rfcOnly(fail("syntax.local.invalid_char", 0))
1805
+ },
1806
+ {
1807
+ address: "\"Fred\\ Bloggs\"@example.com",
1808
+ description: "Escaped space in a quoted string",
1809
+ feature: "quoted-pair",
1810
+ expected: rfcOnly(fail("syntax.local.invalid_char", 0))
1811
+ },
1812
+ {
1813
+ address: "\"Joe.\\\\Blow\"@example.com",
1814
+ description: "Escaped backslash in a quoted string",
1815
+ feature: "quoted-pair",
1816
+ expected: rfcOnly(fail("syntax.local.invalid_char", 0))
1817
+ },
1818
+ {
1819
+ address: "\"Abc@def\"@example.com",
1820
+ description: "Quoted @",
1821
+ feature: "quoted-local",
1822
+ expected: rfcOnly(fail("syntax.local.invalid_char", 0))
1823
+ },
1824
+ {
1825
+ address: "\"Fred Bloggs\"@example.com",
1826
+ description: "Quoted space",
1827
+ feature: "quoted-local",
1828
+ expected: rfcOnly(fail("syntax.local.invalid_char", 0))
1829
+ },
1830
+ {
1831
+ address: "user+mailbox@example.com",
1832
+ description: "Plus sign",
1833
+ feature: "atext-specials",
1834
+ expected: everywhere(valid)
1835
+ },
1836
+ {
1837
+ address: "customer/department=shipping@example.com",
1838
+ description: "Slash and equals sign",
1839
+ feature: "atext-specials",
1840
+ expected: everywhere(valid)
1841
+ },
1842
+ {
1843
+ address: "$A12345@example.com",
1844
+ description: "Dollar sign first",
1845
+ feature: "atext-specials",
1846
+ expected: everywhere(valid)
1847
+ },
1848
+ {
1849
+ address: "!def!xyz%abc@example.com",
1850
+ description: "Bang path and percent route",
1851
+ feature: "route-chars",
1852
+ expected: {
1853
+ ...everywhere(valid),
1854
+ practical: fail("syntax.local.invalid_char", 0)
1855
+ }
1856
+ },
1857
+ {
1858
+ address: "_somename@example.com",
1859
+ description: "Underscore first",
1860
+ feature: "atext-specials",
1861
+ expected: everywhere(valid)
1862
+ }
1863
+ ];
1864
+ //#endregion
1865
+ //#region src/fixtures/wikipedia.ts
1866
+ const wikipediaFixtures = [
1867
+ {
1868
+ address: "FirstName.LastName@EasierReading.org",
1869
+ description: "Mixed case",
1870
+ feature: "dot-atom",
1871
+ expected: everywhere(valid)
1872
+ },
1873
+ {
1874
+ address: "long.email-address-with-hyphens@and.subdomains.example.com",
1875
+ description: "Hyphens in the local part, subdomains",
1876
+ feature: "atext-specials",
1877
+ expected: everywhere(valid)
1878
+ },
1879
+ {
1880
+ address: "name/surname@example.com",
1881
+ description: "Slash in the local part",
1882
+ feature: "atext-specials",
1883
+ expected: everywhere(valid)
1884
+ },
1885
+ {
1886
+ address: "admin@example",
1887
+ description: "Domain with no dot",
1888
+ feature: "dotless-domain",
1889
+ expected: {
1890
+ ...everywhere(fail("syntax.domain.no_dot")),
1891
+ html5: valid
1892
+ }
1893
+ },
1894
+ {
1895
+ address: "example@s.example",
1896
+ description: "Reserved TLD",
1897
+ feature: "unknown-tld",
1898
+ expected: {
1899
+ ...everywhere(valid),
1900
+ practical: fail("syntax.tld.unknown")
1901
+ }
1902
+ },
1903
+ {
1904
+ address: "\"jane..doe\"@example.org",
1905
+ description: "Consecutive dots inside a quoted local part",
1906
+ feature: "quoted-local",
1907
+ expected: rfcOnly(fail("syntax.local.invalid_char", 0))
1908
+ },
1909
+ {
1910
+ address: "\"very.(),:;<>[]\\\".VERY.\\\"very@\\\\ \\\"very\\\".unusual\"@strange.example.com",
1911
+ description: "Quoted string with specials, an @, and escapes",
1912
+ feature: "quoted-pair",
1913
+ expected: rfcOnly(fail("syntax.local.invalid_char", 0))
1914
+ },
1915
+ {
1916
+ address: "postmaster@[123.123.123.123]",
1917
+ description: "IPv4 address literal",
1918
+ feature: "ipv4-literal",
1919
+ expected: rfcOnly(fail("syntax.domain.invalid_char", 11))
1920
+ },
1921
+ {
1922
+ address: "postmaster@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:7334]",
1923
+ description: "IPv6 address literal",
1924
+ feature: "ipv6-literal",
1925
+ expected: rfcOnly(fail("syntax.domain.invalid_char", 11))
1926
+ },
1927
+ {
1928
+ address: "_test@[IPv6:2001:0db8:85a3:0000:0000:8a2e:0370:7334]",
1929
+ description: "Underscore first, IPv6 address literal",
1930
+ feature: "ipv6-literal",
1931
+ expected: rfcOnly(fail("syntax.domain.invalid_char", 6))
1932
+ },
1933
+ {
1934
+ address: "I❤️CHOCOLATE@example.com",
1935
+ description: "Emoji in the local part",
1936
+ expected: everywhere(fail("syntax.local.invalid_char", 1))
1937
+ },
1938
+ {
1939
+ address: "abc.example.com",
1940
+ description: "No @",
1941
+ expected: everywhere(fail("syntax.address.no_at"))
1942
+ },
1943
+ {
1944
+ address: "a@b@c@example.com",
1945
+ description: "More than one @",
1946
+ expected: everywhere(fail("syntax.local.invalid_char", 1))
1947
+ },
1948
+ {
1949
+ address: "this is\"not\\allowed@example.com",
1950
+ description: "Unquoted space, quote, and backslash",
1951
+ expected: everywhere(fail("syntax.local.unquoted_space", 4))
1952
+ },
1953
+ {
1954
+ address: "this\\ still\\\"not\\\\allowed@example.com",
1955
+ description: "Backslash escapes outside a quoted string",
1956
+ expected: everywhere(fail("syntax.local.invalid_char", 4))
1957
+ },
1958
+ {
1959
+ address: "i.like.underscores@but_they_are_not_allowed_in_this_part",
1960
+ description: "Underscores in a dotless domain",
1961
+ expected: allBut5322(fail("syntax.domain.invalid_char", 22), fail("syntax.domain.no_dot"))
1962
+ }
1963
+ ];
1964
+ //#endregion
1965
+ //#region src/fixtures/index.ts
1966
+ /**
1967
+ * The syntax corpus, published as `@email-utils/validator-syntax/fixtures`
1968
+ * so dependents can check they split and judge addresses exactly as
1969
+ * `parseAddress` does, and so the docs can build the support matrix.
1970
+ *
1971
+ * @remarks
1972
+ * Every fixture's `expected` is the result under each preset's default
1973
+ * options. The rules behind them:
1974
+ *
1975
+ * - `practical`: a dot-atom local part (letters, digits, and
1976
+ * ``#$&'*+/=?^_`{|}~-`` with single inner dots), so no quoted strings, no
1977
+ * `%` or `!` routes, and no comments or whitespace; hostname labels with at
1978
+ * least one dot, and no domain literals; the TLD in the IANA set.
1979
+ * - `rfc5321`: an RFC 5321 Dot-string or Quoted-string local part, never
1980
+ * both mixed, capped at 64 characters; hostname labels with at least one
1981
+ * dot, or an IPv4 or `IPv6:` address literal (IPv6 is the only registered
1982
+ * tag, and no more than six groups may sit beside a `::`); no comments or
1983
+ * whitespace.
1984
+ * - `rfc5322`: RFC 5322's addr-spec with its obsolete syntax: dot-separated
1985
+ * atoms and quoted strings mixed, comments and folding whitespace around
1986
+ * every word and label, control characters in quoted strings, comments,
1987
+ * and escapes, and any dtext in a domain literal. Domain labels are
1988
+ * atext, since RFC 5322's domain is a dot-atom, with the hostname rules
1989
+ * for hyphens and length on top. A CRLF must be followed by a space or
1990
+ * tab. No 64-character local cap, but a dotted domain is still required.
1991
+ * - `html5`: exactly the WHATWG `input[type=email]` regex.
1992
+ *
1993
+ * Every preset caps a domain label at 63 characters and the address at 254;
1994
+ * all but `html5` cap the domain at 253. Comments and folding whitespace
1995
+ * don't count toward the caps.
1996
+ *
1997
+ * The address splits on the last `@` outside a quoted string, comment, or
1998
+ * domain literal (validator-syntax#9). A quote opens a quoted string only at
1999
+ * the start of a word; anywhere else it's an invalid character. A quoted
2000
+ * string, comment, or literal left open runs to the end, taking any `@`
2001
+ * with it.
2002
+ *
2003
+ * The first failure wins, checked in this order: empty input; the split;
2004
+ * the local part, left to right, then its length; the domain, left to right,
2005
+ * then its length; the address length; a dotless domain; the TLD. Where a
2006
+ * failure has a position, `index` points at the first offending character
2007
+ * in the whole address: the `(` of a disallowed or unterminated comment,
2008
+ * the `[` of a bad domain literal, the start of an overlong label, and the
2009
+ * CR of a CRLF that isn't followed by whitespace.
2010
+ *
2011
+ * @packageDocumentation
2012
+ */
2013
+ /** Every fixture from every source, each address once. */
2014
+ const syntaxFixtures = [
2015
+ ...legacyFixtures,
2016
+ ...isemailFixtures,
2017
+ ...wikipediaFixtures,
2018
+ ...rfc3696Fixtures
2019
+ ];
2020
+ /** The docs' support matrix: one row per feature, one column per preset. */
2021
+ function supportMatrix() {
2022
+ return syntaxFeatures.map(({ feature, label }) => {
2023
+ const fixtures = syntaxFixtures.filter((fixture) => fixture.feature === feature);
2024
+ const supportIn = (preset) => {
2025
+ const accepted = fixtures.filter((fixture) => fixture.expected[preset].ok).length;
2026
+ if (accepted === fixtures.length) return "yes";
2027
+ return accepted === 0 ? "no" : "partial";
2028
+ };
2029
+ return {
2030
+ feature,
2031
+ label,
2032
+ support: {
2033
+ practical: supportIn("practical"),
2034
+ rfc5321: supportIn("rfc5321"),
2035
+ rfc5322: supportIn("rfc5322"),
2036
+ html5: supportIn("html5")
2037
+ },
2038
+ fixtures
2039
+ };
2040
+ });
2041
+ }
2042
+ /**
2043
+ * Runs `addresses` through `createSyntaxValidator(options)` and splits them
2044
+ * into the ones it accepts and the ones it rejects, each list in input
2045
+ * order.
2046
+ *
2047
+ * @remarks
2048
+ * `changed` marks the addresses the overrides move: those the preset alone
2049
+ * would judge the other way. With no overrides, nothing is changed.
2050
+ *
2051
+ * @example
2052
+ * ```ts
2053
+ * const { valid, invalid } = previewSyntaxOptions({ checkTld: false });
2054
+ * valid.filter((entry) => entry.changed); // now accepted, e.g. example@s.example
2055
+ * previewSyntaxOptions({ preset: 'html5' }, ['ada@localhost']).valid; // [{ address: 'ada@localhost', changed: false }]
2056
+ * ```
2057
+ *
2058
+ * @param addresses - The addresses to judge; `syntaxFixtures` by default.
2059
+ * @throws TypeError when `options` are malformed, or `addresses` isn't an
2060
+ * array of strings.
2061
+ */
2062
+ function previewSyntaxOptions(options, addresses) {
2063
+ const validator = (0, _email_utils_validator_syntax.createSyntaxValidator)(options);
2064
+ const preset = (0, _email_utils_validator_syntax.createSyntaxValidator)({ preset: options?.preset });
2065
+ const entries = addresses === void 0 ? syntaxFixtures : own(addresses);
2066
+ const valid = [];
2067
+ const invalid = [];
2068
+ for (const { address, description } of entries) {
2069
+ const result = validator.parse(address);
2070
+ const described = description === void 0 ? {} : { description };
2071
+ if (result.ok) {
2072
+ const changed = !preset.isValid(address);
2073
+ valid.push({
2074
+ address,
2075
+ ...described,
2076
+ changed
2077
+ });
2078
+ } else {
2079
+ const { ok: _, ...failure } = result;
2080
+ invalid.push({
2081
+ address,
2082
+ ...described,
2083
+ ...failure,
2084
+ changed: preset.isValid(address)
2085
+ });
2086
+ }
2087
+ }
2088
+ return {
2089
+ valid,
2090
+ invalid
2091
+ };
2092
+ }
2093
+ /** Checks the caller's addresses, before any of them is parsed. */
2094
+ function own(addresses) {
2095
+ if (!Array.isArray(addresses)) throw new TypeError("Expected the addresses to be an array");
2096
+ return addresses.map((address, i) => {
2097
+ if (typeof address !== "string") throw new TypeError(`Expected addresses[${i}] to be a string`);
2098
+ return { address };
2099
+ });
2100
+ }
2101
+ //#endregion
2102
+ exports.isemailFixtures = isemailFixtures;
2103
+ exports.legacyFixtures = legacyFixtures;
2104
+ exports.presets = presets;
2105
+ exports.previewSyntaxOptions = previewSyntaxOptions;
2106
+ exports.rfc3696Fixtures = rfc3696Fixtures;
2107
+ exports.supportMatrix = supportMatrix;
2108
+ exports.syntaxFeatures = syntaxFeatures;
2109
+ exports.syntaxFixtures = syntaxFixtures;
2110
+ exports.wikipediaFixtures = wikipediaFixtures;
2111
+
2112
+ //# sourceMappingURL=fixtures.cjs.map