MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _quote

Function _quote

tools/python-3.11.9-amd64/Lib/http/cookies.py:174–184  ·  view source on GitHub ↗

r"""Quote a string for use in a cookie header. If the string does not need to be double-quoted, then just return the string. Otherwise, surround the string in doublequotes and quote (with a \) special characters.

(str)

Source from the content-addressed store, hash-verified

172_is_legal_key = re.compile('[%s]+' % re.escape(_LegalChars)).fullmatch
173
174def _quote(str):
175 r"""Quote a string for use in a cookie header.
176
177 If the string does not need to be double-quoted, then just return the
178 string. Otherwise, surround the string in doublequotes and quote
179 (with a \) special characters.
180 """
181 if str is None or _is_legal_key(str):
182 return str
183 else:
184 return '"' + str.translate(_Translator) + '"'
185
186
187_OctalPatt = re.compile(r"\\[0-3][0-7][0-7]")

Callers 3

OutputStringMethod · 0.85
value_encodeMethod · 0.85
quoteFunction · 0.85

Calls 1

translateMethod · 0.80

Tested by

no test coverage detected