-
-
Notifications
You must be signed in to change notification settings - Fork 839
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix console markup escaping issue #1866
Conversation
with rich.progress.Progress( | ||
"[progress.description]{task.description}", | ||
"[progress.percentage]{task.percentage:>3.0f}%", | ||
rich.progress.BarColumn(bar_width=None), | ||
rich.progress.DownloadColumn(), | ||
rich.progress.TransferSpeedColumn(), | ||
) as progress: | ||
description = f"Downloading [bold]{download.name}" | ||
download_task = progress.add_task(description, **kwargs) # type: ignore | ||
description = f"Downloading [bold]{rich.markup.escape(download.name)}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for this :)
I think this is the only relevant change in this PR wrt the "markup leak" issue, right? By only adding that rich.markup.escape()
call I was able to prevent eg --download "[blink red]file.out"
from rendering.
I'm not sure what the effect of the syntax
and kwargs
bits are, but they seem non-related, so they should be kept out, sounds legit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mainly the markup leak.
Replacing the kwargs was partly a simplification, but also covers the situation where there is no content length in the header. Consequently Rich will show a "in progress animation" rather than remain stuck at 0% until the download was finished.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM :-)
Thanks @willmcgugan! |
Escapes the download name so that it won't render console markup.