Scan printables/quoted-pairs until endchars and return unquoted ptext. This function turns a run of qcontent, ccontent-without-comments, or dtext-with-quoted-printables into a single string by unquoting any quoted printables. It returns the string, the remaining value, and a flag t
(value, endchars)
| 1029 | "Non-ASCII characters found in header token")) |
| 1030 | |
| 1031 | def _get_ptext_to_endchars(value, endchars): |
| 1032 | """Scan printables/quoted-pairs until endchars and return unquoted ptext. |
| 1033 | |
| 1034 | This function turns a run of qcontent, ccontent-without-comments, or |
| 1035 | dtext-with-quoted-printables into a single string by unquoting any |
| 1036 | quoted printables. It returns the string, the remaining value, and |
| 1037 | a flag that is True iff there were any quoted printables decoded. |
| 1038 | |
| 1039 | """ |
| 1040 | if not value: |
| 1041 | return '', '', False |
| 1042 | fragment, *remainder = _wsp_splitter(value, 1) |
| 1043 | vchars = [] |
| 1044 | escape = False |
| 1045 | had_qp = False |
| 1046 | for pos in range(len(fragment)): |
| 1047 | if fragment[pos] == '\\': |
| 1048 | if escape: |
| 1049 | escape = False |
| 1050 | had_qp = True |
| 1051 | else: |
| 1052 | escape = True |
| 1053 | continue |
| 1054 | if escape: |
| 1055 | escape = False |
| 1056 | elif fragment[pos] in endchars: |
| 1057 | break |
| 1058 | vchars.append(fragment[pos]) |
| 1059 | else: |
| 1060 | pos = pos + 1 |
| 1061 | return ''.join(vchars), ''.join([fragment[pos:]] + remainder), had_qp |
| 1062 | |
| 1063 | def get_fws(value): |
| 1064 | """FWS = 1*WSP |
no test coverage detected
searching dependent graphs…