Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-146385: Switch back tore to detect shlex.quote slow path#146408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
bonzini wants to merge1 commit intopython:main
base:main
Choose a base branch
Loading
frombonzini:fix146385
Open
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletionsLib/shlex.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -317,20 +317,22 @@ def join(split_command):
return ' '.join(quote(arg) for arg in split_command)


def _find_unsafe_lazy(s):
import re # deferred import and compilation for performance

global _find_unsafe
_find_unsafe = re.compile(r'[^\w@%+=:,./-]', re.ASCII).search
return _find_unsafe(s)


_find_unsafe = _find_unsafe_lazy


def quote(s):
"""Return a shell-escaped version of the string *s*."""
if not s:
return "''"

if not isinstance(s, str):
raise TypeError(f"expected string object, got {type(s).__name__!r}")

# Use bytes.translate() for performance
safe_chars = (b'%+,-./0123456789:=@'
b'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'
b'abcdefghijklmnopqrstuvwxyz')
# No quoting is needed if `s` is an ASCII string consisting only of `safe_chars`
if s.isascii() and not s.encode().translate(None, delete=safe_chars):
if _find_unsafe(s) is None:
return s

# use single quotes, and put single quotes into double quotes
Expand Down
Loading

[8]ページ先頭

©2009-2026 Movatter.jp