Skip to content
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

Merged
merged 8 commits into from
Feb 4, 2022
Merged

Conversation

willmcgugan
Copy link
Contributor

Escapes the download name so that it won't render console markup.

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)}"
Copy link
Member

@florimondmanca florimondmanca Oct 18, 2021

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?

Copy link
Contributor Author

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.

Copy link
Member

@florimondmanca florimondmanca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :-)

@tomchristie
Copy link
Member

Thanks @willmcgugan!

@tomchristie tomchristie merged commit 2814fd3 into encode:master Feb 4, 2022
@tomchristie tomchristie mentioned this pull request May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants