Like quote(), but also replace ' ' with '+', as required for quoting HTML form values. Plus signs in the original string are escaped unless they are included in safe. It also does not have safe default to '/'.
(string, safe='', encoding=None, errors=None)
| 952 | return quote_from_bytes(string, safe) |
| 953 | |
| 954 | def quote_plus(string, safe='', encoding=None, errors=None): |
| 955 | """Like quote(), but also replace ' ' with '+', as required for quoting |
| 956 | HTML form values. Plus signs in the original string are escaped unless |
| 957 | they are included in safe. It also does not have safe default to '/'. |
| 958 | """ |
| 959 | # Check if ' ' in string, where string may either be a str or bytes. If |
| 960 | # there are no spaces, the regular quote will produce the right answer. |
| 961 | if ((isinstance(string, str) and ' ' not in string) or |
| 962 | (isinstance(string, bytes) and b' ' not in string)): |
| 963 | return quote(string, safe, encoding, errors) |
| 964 | if isinstance(safe, str): |
| 965 | space = ' ' |
| 966 | else: |
| 967 | space = b' ' |
| 968 | string = quote(string, safe + space, encoding, errors) |
| 969 | return string.replace(' ', '+') |
| 970 | |
| 971 | # Expectation: A typical program is unlikely to create more than 5 of these. |
| 972 | @functools.lru_cache |
nothing calls this directly
no test coverage detected