-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Fixed the escaping of back slashes and << in console output #23730
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
@@ -50,7 +50,7 @@ public static function escapeTrailingBackslash($text) | |||
if ('\\' === substr($text, -1)) { | |||
$len = strlen($text); | |||
$text = rtrim($text, '\\'); | |||
$text .= str_repeat('<<', $len - strlen($text)); | |||
$text .= str_repeat('\0', $len - strlen($text)); |
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.
so, this relies on the fact that \0 is not printable, to use it as an escape character?
to be safe, what about removing \0
from $text also?
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.
Note that currently the PR does not use the null character but a backslash followed by a zero. Wouldn't it be better to actually use the null character ("\0"
instead of '\0'
)?
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.
tested with "\0"
on 3.0.4 and seems to work, thanks @javiereguiluz for picking this up, much appreciated 👍 :)
Thanks for the reviews! I've fixed the error pointed out by @julienfalque. About this question from @nicolas-grekas:
I'm not sure I fully understand what you mean. Can you show me the code changes you want me to do? Thanks! |
@@ -50,7 +50,7 @@ public static function escapeTrailingBackslash($text) | |||
if ('\\' === substr($text, -1)) { | |||
$len = strlen($text); | |||
$text = rtrim($text, '\\'); | |||
$text .= str_repeat('<<', $len - strlen($text)); |
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 meant this here:
$text = str_replace("\0", '', $text);
(or more generally: what happens/should happen when $text already has "\0" in it?)
Thank you @javiereguiluz. |
…t (javiereguiluz) This PR was squashed before being merged into the 2.7 branch (closes #23730). Discussion ---------- Fixed the escaping of back slashes and << in console output | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #18481 | License | MIT | Doc PR | - Not sure if it's a valid solution, but this is my attempt to solve #18481. Commits ------- d5cb1fe Fixed the escaping of back slashes and << in console output
Not sure if it's a valid solution, but this is my attempt to solve #18481.