Given a filename to be used in a multipart/form-data, encode the name. Return the key and encoded filename.
(filename)
| 26 | |
| 27 | |
| 28 | def 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 | |
| 43 | def encode_multipart_formdata(files): |
no test coverage detected
searching dependent graphs…