MCPcopy
hub / github.com/cherrypy/cherrypy / encode_filename

Function encode_filename

cherrypy/test/test_http.py:28–40  ·  view source on GitHub ↗

Given a filename to be used in a multipart/form-data, encode the name. Return the key and encoded filename.

(filename)

Source from the content-addressed store, hash-verified

26
27
28def encode_filename(filename):
29 """Given a filename to be used in a multipart/form-data, encode the name.
30
31 Return the key and encoded filename.
32 """
33 if is_ascii(filename):
34 return 'filename', '"{filename}"'.format(**locals())
35 encoded = urllib.parse.quote(filename, encoding='utf-8')
36 return 'filename*', "'".join((
37 'UTF-8',
38 '', # lang
39 encoded,
40 ))
41
42
43def encode_multipart_formdata(files):

Callers 1

Calls 3

is_asciiFunction · 0.85
formatMethod · 0.80
joinMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…