MCPcopy Index your code
hub / github.com/RustPython/RustPython / _get_ptext_to_endchars

Function _get_ptext_to_endchars

Lib/email/_header_value_parser.py:1014–1044  ·  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

1012 "Non-ASCII characters found in header token"))
1013
1014def _get_ptext_to_endchars(value, endchars):
1015 """Scan printables/quoted-pairs until endchars and return unquoted ptext.
1016
1017 This function turns a run of qcontent, ccontent-without-comments, or
1018 dtext-with-quoted-printables into a single string by unquoting any
1019 quoted printables. It returns the string, the remaining value, and
1020 a flag that is True iff there were any quoted printables decoded.
1021
1022 """
1023 if not value:
1024 return '', '', False
1025 fragment, *remainder = _wsp_splitter(value, 1)
1026 vchars = []
1027 escape = False
1028 had_qp = False
1029 for pos in range(len(fragment)):
1030 if fragment[pos] == '\\':
1031 if escape:
1032 escape = False
1033 had_qp = True
1034 else:
1035 escape = True
1036 continue
1037 if escape:
1038 escape = False
1039 elif fragment[pos] in endchars:
1040 break
1041 vchars.append(fragment[pos])
1042 else:
1043 pos = pos + 1
1044 return ''.join(vchars), ''.join([fragment[pos:]] + remainder), had_qp
1045
1046def get_fws(value):
1047 """FWS = 1*WSP

Callers 3

get_qp_ctextFunction · 0.85
get_qcontentFunction · 0.85
get_dtextFunction · 0.85

Calls 3

lenFunction · 0.85
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected