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

Appearance settings
Merged
Changes from all 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
5 changes: 4 additions & 1 deletion 5 kasa/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,17 @@
try:
from rich import print as _do_echo
except ImportError:
# Remove 7-bit C1 ANSI sequences
# https://stackoverflow.com/questions/14693701/how-can-i-remove-the-ansi-escape-sequences-from-a-string-in-python
ansi_escape = re.compile(r"\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])")

Check warning

Code scanning / CodeQL

Overly permissive regular expression range

Suspicious character range that is equivalent to \[@A-Z\].

Check warning

Code scanning / CodeQL

Overly permissive regular expression range

Suspicious character range that is equivalent to \[0-9:;<=>?\].

def _strip_rich_formatting(echo_func):
"""Strip rich formatting from messages."""

@wraps(echo_func)
def wrapper(message=None, *args, **kwargs):
if message is not None:
message = re.sub(r"\[/?.+?]", "", message)
message = ansi_escape.sub("", message)
echo_func(message, *args, **kwargs)

return wrapper
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.