| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -317,8 +317,12 @@ def join(split_command): | |||
| 317 | 317 | return ' '.join(quote(arg) for arg in split_command) | |
| 318 | 318 | ||
| 319 | 319 | ||
| 320 | - def quote(s): | ||
| 321 | - """Return a shell-escaped version of the string *s*.""" | ||
| 320 | + def quote(s, force=False): | ||
| 321 | + """Return a shell-escaped version of the string *s*. | ||
| 322 | + | ||
| 323 | + If *force* is *True* then *s* will be quoted even if it is | ||
| 324 | + already safe for a shell without being quoted. | ||
| 325 | + """ | ||
| 322 | 326 | if not s: | |
| 323 | 327 | return "''" | |
| 324 | 328 | ||
@@ -329,8 +333,11 @@ def quote(s): | |||
| 329 | 333 | safe_chars = (b'%+,-./0123456789:=@' | |
| 330 | 334 | b'ABCDEFGHIJKLMNOPQRSTUVWXYZ_' | |
| 331 | 335 | b'abcdefghijklmnopqrstuvwxyz') | |
| 332 | - # No quoting is needed if `s` is an ASCII string consisting only of `safe_chars` | ||
| 333 | - if s.isascii() and not s.encode().translate(None, delete=safe_chars): | ||
| 336 | + if (not force | ||
| 337 | + and s.isascii() and not s.encode().translate(None, delete=safe_chars) | ||
| 338 | + ): | ||
| 339 | + # No quoting is needed if we're not forcing quoting | ||
| 340 | + # and `s` is an ASCII string consisting only of `safe_chars` | ||
| 334 | 341 | return s | |
| 335 | 342 | ||
| 336 | 343 | # use single quotes, and put single quotes into double quotes | |
| Back | FazBrowse Home | New Git URL |
0 commit comments