MCPcopy Index your code
hub / github.com/python/cpython / _get_ptext_to_endchars

Function _get_ptext_to_endchars

Lib/email/_header_value_parser.py:1031–1061  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1029 "Non-ASCII characters found in header token"))
1030
1031def _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
1063def get_fws(value):
1064 """FWS = 1*WSP

Callers 3

get_qp_ctextFunction · 0.85
get_qcontentFunction · 0.85
get_dtextFunction · 0.85

Calls 2

appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…