-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Fixes "Incorrectly nested style tag found" error when using multi-line header content #46114
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
[Console] Fixes "Incorrectly nested style tag found" error when using multi-line header content #46114
Conversation
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
I changed the target branch to 6.1 as that's what your branch is currently based on, allowing to have a clean diff. The expected target of the bugfix (which will require rebasing the git branch, not only editing the PR metadata) is either 4.4 or 5.4 (depending on whether 4.4 is affected, which is probably the case as you said that this code hasn't changed since 2017). But there is no chance that the lowest affected version is 6.0 |
Yeah, I think I'm misunderstanding where to branch from , It's not difficult to create a patch for this since it's such a tiny change. Is there a branch I should be creating this from to PR into? |
@Perturbatio if the lowest affected maintained version is 4.4 (which is likely the case for this bug), the fix needs to be applied to 4.4. The easiest for that is to create your branch directly from the 4.4 branch. But you can still change that after the fact with a rebase. See https://symfony.com/doc/current/contributing/code/pull_requests.html#rebase-your-pull-request (be careful about the last step requiring a force push, not a merge of the upstream feature branch, which is a common mistake done when following that doc not carefully) |
@stof The current set of failing tests (TextDescriptorTest) pass locally, but in GitHub (only in |
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.
Please revert all unrelated CS changes, so that the PR is focused on one topic.
… multi-line header content
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.
(I reverted the not-needed CS changes)
Thank you @Perturbatio. |
This is intended to fix a bug identified as a result of usage in a separate package (hotmeteor/spectator#69 and hotmeteor/spectator#90).
When a multi-line string is provided in the headers the Table helper produces content that cannot be rendered correctly.
in
src/Symfony/Component/Console/Helper/Table.php
there's a line$lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell))
the exact line version varies between package versions, but this hasn't changed since 2017.What this seems to do when you pass a multi line terminal string is wrap the newlines in a default style tag, presumably to try to force a reset.
But what happens in the headers is that it splits it so that each line after the first starts with the close tag and ends with the open, resulting in the incorrect nesting error. All this does is shift the newline character to after the reset style tag. A side-effect of this is that it appears to now pad out the content of the
compact
andborderless
styles in a manner which (to me) appears to be the intended output i.e. spaces padded out to the full table width.