Commit 63093a8
Security: fix domain octet limits, block Variation Selectors, drop .inverted on supplementary-plane sets
RFC compliance (Bug 1):
- Domain total-length check now uses .utf8.count ≤ 253 (was .count)
- Per-label length check now uses .utf8.count ≤ 63 (was .count)
- RFC 1035 §2.3.4 specifies octets; multi-byte Unicode labels could
previously exceed the byte limit while passing the character-count check
Spoofing prevention (Bug 2):
- Add U+FE00-U+FE0F (Variation Selectors) to zeroWidthAndInvisibleChars
so they are subtracted from atextUnicode/qtextUnicode character sets
- Add explicit scalar guards for U+E0100-U+E01EF (Variation Selectors
Supplement) in extractDotAtom and extractQuotedString
- VS chars combine invisibly with adjacent base characters; "user\uFE01"
renders identically to "user" — same spoofing risk as ZWJ/ZWNJ
Foundation CharacterSet bug (Bug 3):
- Replace .inverted usage on sets containing supplementary planes with
per-scalar allSatisfy({ set.contains($0) }) throughout:
extractDotAtom (disallowedCharacterSet → allowedCharacterSet),
candidateForRfc2047 (rangeOfCharacter inverted check)
- Foundation's CharacterSet bitmap inversion is unreliable for
supplementary-plane scalars; direct containment queries are not
Tests: add testDomainLabelUnicodeByteLengthEnforced,
testTotalDomainUnicodeByteLengthEnforced,
testVariationSelectorsRejectedInLocalPart (BMP + Supplement)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 28643ae commit 63093a8
2 files changed
Lines changed: 113 additions & 14 deletions
File tree
- Sources/SwiftEmailValidator
- Tests/SwiftEmailValidatorTests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
| 200 | + | |
200 | 201 | | |
201 | 202 | | |
202 | | - | |
| 203 | + | |
203 | 204 | | |
204 | 205 | | |
205 | 206 | | |
| |||
235 | 236 | | |
236 | 237 | | |
237 | 238 | | |
238 | | - | |
239 | | - | |
| 239 | + | |
| 240 | + | |
240 | 241 | | |
241 | 242 | | |
242 | 243 | | |
243 | 244 | | |
244 | 245 | | |
245 | 246 | | |
246 | 247 | | |
247 | | - | |
| 248 | + | |
248 | 249 | | |
249 | 250 | | |
250 | 251 | | |
| |||
305 | 306 | | |
306 | 307 | | |
307 | 308 | | |
| 309 | + | |
308 | 310 | | |
309 | 311 | | |
310 | 312 | | |
| |||
369 | 371 | | |
370 | 372 | | |
371 | 373 | | |
372 | | - | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
373 | 378 | | |
374 | 379 | | |
375 | 380 | | |
376 | 381 | | |
377 | 382 | | |
378 | 383 | | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
383 | 394 | | |
384 | 395 | | |
385 | 396 | | |
| |||
418 | 429 | | |
419 | 430 | | |
420 | 431 | | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
426 | 439 | | |
427 | 440 | | |
428 | 441 | | |
| |||
Lines changed: 86 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
479 | 479 | | |
480 | 480 | | |
481 | 481 | | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
482 | 525 | | |
483 | 526 | | |
484 | 527 | | |
| |||
641 | 684 | | |
642 | 685 | | |
643 | 686 | | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
644 | 730 | | |
645 | 731 | | |
646 | 732 | | |
| |||
0 commit comments