Commit fe29bad
authored
Reject NUL, CR and LF in _raw_command arguments before sending (#658)
CR and LF end the command line on the wire, so an argument carrying
them, for example a search criterion built from a sender-controlled
header, is run by the server as extra commands. _raw_command bypasses
imaplib._command, so CPython's check for the same characters does not
apply here. Check every argument before the first send, so a bad one
never leaves a half-sent command; 8-bit values still go as literals,
which may carry CR and LF. Fixes #657
`literal` is now exported so callers can wrap a value that carries CR or LF,
as the new error message suggests. _literal stays as an alias for code that
imported the old name.
search() quoted any value with a space, so a literal holding CR or LF came
out as a _quoted string and the new check rejected it, even though the
error message says to wrap the value in literal.1 parent 4090d8e commit fe29bad
3 files changed
Lines changed: 71 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
1461 | 1462 | | |
1462 | 1463 | | |
1463 | 1464 | | |
1464 | | - | |
| 1465 | + | |
1465 | 1466 | | |
1466 | | - | |
| 1467 | + | |
1467 | 1468 | | |
1468 | 1469 | | |
1469 | 1470 | | |
| |||
1709 | 1710 | | |
1710 | 1711 | | |
1711 | 1712 | | |
1712 | | - | |
1713 | | - | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
1714 | 1717 | | |
1715 | 1718 | | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
1716 | 1729 | | |
| 1730 | + | |
| 1731 | + | |
1717 | 1732 | | |
1718 | 1733 | | |
1719 | 1734 | | |
| |||
1872 | 1887 | | |
1873 | 1888 | | |
1874 | 1889 | | |
| 1890 | + | |
| 1891 | + | |
1875 | 1892 | | |
1876 | 1893 | | |
1877 | 1894 | | |
| |||
1883 | 1900 | | |
1884 | 1901 | | |
1885 | 1902 | | |
1886 | | - | |
| 1903 | + | |
1887 | 1904 | | |
1888 | 1905 | | |
1889 | 1906 | | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
1890 | 1910 | | |
1891 | 1911 | | |
1892 | 1912 | | |
| |||
1979 | 1999 | | |
1980 | 2000 | | |
1981 | 2001 | | |
1982 | | - | |
| 2002 | + | |
1983 | 2003 | | |
1984 | 2004 | | |
1985 | 2005 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | 18 | | |
20 | 19 | | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
419 | | - | |
| 419 | + | |
420 | 420 | | |
421 | | - | |
| 421 | + | |
422 | 422 | | |
423 | | - | |
| 423 | + | |
424 | 424 | | |
425 | 425 | | |
426 | 426 | | |
| |||
749 | 749 | | |
750 | 750 | | |
751 | 751 | | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
752 | 786 | | |
753 | 787 | | |
754 | 788 | | |
| |||
1006 | 1040 | | |
1007 | 1041 | | |
1008 | 1042 | | |
1009 | | - | |
| 1043 | + | |
1010 | 1044 | | |
1011 | 1045 | | |
1012 | 1046 | | |
| |||
1020 | 1054 | | |
1021 | 1055 | | |
1022 | 1056 | | |
1023 | | - | |
| 1057 | + | |
1024 | 1058 | | |
1025 | 1059 | | |
1026 | 1060 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
139 | 140 | | |
140 | 141 | | |
141 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
142 | 147 | | |
143 | 148 | | |
144 | 149 | | |
| |||
0 commit comments