MCPcopy
hub / github.com/pallets/werkzeug / _plain_int

Function _plain_int

src/werkzeug/_internal.py:199–211  ·  view source on GitHub ↗

Parse an int only if it is only ASCII digits and ``-``. This disallows ``+``, ``_``, and non-ASCII digits, which are accepted by ``int`` but are not allowed in HTTP header values. Any leading or trailing whitespace is stripped

(value: str)

Source from the content-addressed store, hash-verified

197
198
199def _plain_int(value: str) -> int:
200 """Parse an int only if it is only ASCII digits and ``-``.
201
202 This disallows ``+``, ``_``, and non-ASCII digits, which are accepted by ``int`` but
203 are not allowed in HTTP header values.
204
205 Any leading or trailing whitespace is stripped
206 """
207 value = value.strip()
208 if _plain_int_re.fullmatch(value) is None:
209 raise ValueError
210
211 return int(value)

Callers 5

start_file_streamingMethod · 0.85
parse_range_headerFunction · 0.85
get_content_lengthFunction · 0.85
content_lengthMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected