-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Update regex used to remove ANSI escape sequences to be more specific to decoration and hyperlinks #16811
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
Conversation
… to decoration and hyperlinks
fix regex for CSI by escaping the question mark
|
Re-assign PR to security WG. |
|
@SteveL-MSFT Sorry if I already said this but I feel we fall in unlimited problems and fixes. I would personally roll back this kind of coloring (it's a far cry from the spirit of PowerShell) and invest in Formatting system enhancement or better in something like PSMore. |
|
@iSazonov PSMore is solving a different problem than PSStyle. The two are not mutually exclusive. ANSI/VT escape sequences are the industry standard way of emitting text decoration and works across ssh, xterm.js, Windows, Linux, macOS, native commands, etc... For PSMore to emit color, it will have to resort to ANSI/VT escape sequences anyways and we would still have this situation. Even if table/list formats don't use ANSI/VT, arbitrary scripts and native commands can and do emit ANSI/VT. |
I don't say about rejecting ESs - they are only implementation details. If we will continue on the way we obviously fall in re-implementing whole Windows Terminal in PowerShell! - there is no other way to ensure full processing of ESs in all scenarios.
This is my main frustration because we are provoking users to use ESs when the spirit and idea of PowerShell has always been to do magical things.
I mentioned PSMore as a way to develop without breaking the existing Formatting System. Sorry for noisy :-) |
|
@iSazonov I fully agree that the current formatting system needs to be revamped, but again, that's independent of ESC seqs. We can always adopt something like spectre.console and have something like "{red}hello {blue}there", although the benefit of "$($psstyle.foreground.red)hello" is you get tab completion. Anyways, I think this discussion is separate from this PR. |
|
@SteveL-MSFT All you say is about string formatting. My proposal is to follow PowerShell spirit and invest in object formatting first. |
|
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
PaulHigin
left a comment
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.
This looks Ok to me. But still need @TravisEz13 look at the regex.
|
@PowerShell/powershell-maintainers Let's get at least one preview release before we approve backport |
|
@SteveL-MSFT Just noticed this PR changed the default |
Formatting work around for: PowerShell/PowerShell#16811
|
🎉 Handy links: |
daxian, were you able to track down someone to answer this question for you, in another PR/Issue/etc perhaps? I'm curious to the answer myself. |
|
My chat with @TravisEz13 suggested this is an intentional change, and |
|
@PowerShell/powershell-maintainers should discuss whether this should be backported. |
|
Maintainers discussed this and have decided to wait until the committee has given a decision on #17455 |
|
/backport to release/v7.2.6 |
|
Started backporting to release/v7.2.6: https://github.com/PowerShell/PowerShell/actions/runs/2784876485
|
|
🎉 Handy links: |
PR Summary
The previous regex to remove ANSI escape sequences was too broad and would remove content that appeared to be ANSI but was not. The change is to have specific regex targeting colors/decoration and CSI ANSI escape sequences (generated by PSReadLine) which are ones used by PS7 and PSReadLine currently.
Hyperlink isn't supported here as no default formatting emits it and the way the escape sequence works it can be too broad.
PR Context
Fix #16730
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).