@@ -801,6 +801,10 @@ def test_get_quoted_string_header_ends_in_qcontent(self):
801
801
self .assertEqual (qs .content , 'bob' )
802
802
self .assertEqual (qs .quoted_value , ' "bob"' )
803
803
804
+ def test_get_quoted_string_cfws_only_raises (self ):
805
+ with self .assertRaises (errors .HeaderParseError ):
806
+ parser .get_quoted_string (' (foo) ' )
807
+
804
808
def test_get_quoted_string_no_quoted_string (self ):
805
809
with self .assertRaises (errors .HeaderParseError ):
806
810
parser .get_quoted_string (' (ab) xyz' )
@@ -1135,6 +1139,10 @@ def test_get_local_part_complex_obsolete_invalid(self):
1135
1139
'@python.org' )
1136
1140
self .assertEqual (local_part .local_part , 'Fred.A.Johnson and dogs' )
1137
1141
1142
+ def test_get_local_part_empty_raises (self ):
1143
+ with self .assertRaises (errors .HeaderParseError ):
1144
+ parser .get_local_part ('' )
1145
+
1138
1146
def test_get_local_part_no_part_raises (self ):
1139
1147
with self .assertRaises (errors .HeaderParseError ):
1140
1148
parser .get_local_part (' (foo) ' )
@@ -1387,6 +1395,10 @@ def test_get_domain_obsolete(self):
1387
1395
'' )
1388
1396
self .assertEqual (domain .domain , 'example.com' )
1389
1397
1398
+ def test_get_domain_empty_raises (self ):
1399
+ with self .assertRaises (errors .HeaderParseError ):
1400
+ parser .get_domain ("" )
1401
+
1390
1402
def test_get_domain_no_non_cfws_raises (self ):
1391
1403
with self .assertRaises (errors .HeaderParseError ):
1392
1404
parser .get_domain (" (foo)\t " )
@@ -1512,6 +1524,10 @@ def test_get_obs_route_no_route_before_end_raises(self):
1512
1524
with self .assertRaises (errors .HeaderParseError ):
1513
1525
parser .get_obs_route ('(foo) @example.com,' )
1514
1526
1527
+ def test_get_obs_route_no_route_before_end_raises2 (self ):
1528
+ with self .assertRaises (errors .HeaderParseError ):
1529
+ parser .get_obs_route ('(foo) @example.com, (foo) ' )
1530
+
1515
1531
def test_get_obs_route_no_route_before_special_raises (self ):
1516
1532
with self .assertRaises (errors .HeaderParseError ):
1517
1533
parser .get_obs_route ('(foo) [abc],' )
@@ -1520,6 +1536,14 @@ def test_get_obs_route_no_route_before_special_raises2(self):
1520
1536
with self .assertRaises (errors .HeaderParseError ):
1521
1537
parser .get_obs_route ('(foo) @example.com [abc],' )
1522
1538
1539
+ def test_get_obs_route_no_domain_after_at_raises (self ):
1540
+ with self .assertRaises (errors .HeaderParseError ):
1541
+ parser .get_obs_route ('@' )
1542
+
1543
+ def test_get_obs_route_no_domain_after_at_raises2 (self ):
1544
+ with self .assertRaises (errors .HeaderParseError ):
1545
+ parser .get_obs_route ('@example.com, @' )
1546
+
1523
1547
# get_angle_addr
1524
1548
1525
1549
def test_get_angle_addr_simple (self ):
@@ -1646,6 +1670,14 @@ def test_get_angle_addr_ends_at_special(self):
1646
1670
self .assertIsNone (angle_addr .route )
1647
1671
self .
assertEqual (
angle_addr .
addr_spec ,
'[email protected] ' )
1648
1672
1673
+ def test_get_angle_addr_empty_raise (self ):
1674
+ with self .assertRaises (errors .HeaderParseError ):
1675
+ parser .get_angle_addr ('' )
1676
+
1677
+ def test_get_angle_addr_left_angle_only_raise (self ):
1678
+ with self .assertRaises (errors .HeaderParseError ):
1679
+ parser .get_angle_addr ('<' )
1680
+
1649
1681
def test_get_angle_addr_no_angle_raise (self ):
1650
1682
with self .assertRaises (errors .HeaderParseError ):
1651
1683
parser .get_angle_addr ('(foo) ' )
@@ -1857,6 +1889,10 @@ def test_get_name_addr_ends_at_special(self):
1857
1889
self .assertIsNone (name_addr .route )
1858
1890
self .
assertEqual (
name_addr .
addr_spec ,
'[email protected] ' )
1859
1891
1892
+ def test_get_name_addr_empty_raises (self ):
1893
+ with self .assertRaises (errors .HeaderParseError ):
1894
+ parser .get_name_addr ('' )
1895
+
1860
1896
def test_get_name_addr_no_content_raises (self ):
1861
1897
with self .assertRaises (errors .HeaderParseError ):
1862
1898
parser .get_name_addr (' (foo) ' )
@@ -2732,6 +2768,10 @@ def test_get_msg_id_empty_id_right(self):
2732
2768
with self .assertRaises (errors .HeaderParseError ):
2733
2769
parser .get_msg_id ("<simplelocal@>" )
2734
2770
2771
+ def test_get_msg_id_no_id_right (self ):
2772
+ with self .assertRaises (errors .HeaderParseError ):
2773
+ parser .get_msg_id ("<simplelocal@" )
2774
+
2735
2775
def test_get_msg_id_with_brackets (self ):
2736
2776
# Microsof Outlook generates non-standard one-off addresses:
2737
2777
# https://learn.microsoft.com/en-us/office/client-developer/outlook/mapi/one-off-addresses
0 commit comments