Skip to content

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

Closed
wants to merge 3 commits into from

Conversation

javiereguiluz
Copy link
Member

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.

@@ -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));
Copy link
Member

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?

Copy link
Contributor

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')?

Copy link
Contributor

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 👍 :)

@javiereguiluz
Copy link
Member Author

Thanks for the reviews! I've fixed the error pointed out by @julienfalque. About this question from @nicolas-grekas:

to be safe, what about removing \0 from $text also?

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

@nicolas-grekas nicolas-grekas Aug 29, 2017

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?)

@fabpot
Copy link
Member

fabpot commented Aug 29, 2017

Thank you @javiereguiluz.

fabpot added a commit that referenced this pull request Aug 29, 2017
…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
@fabpot fabpot closed this Aug 29, 2017
@fabpot fabpot mentioned this pull request Sep 11, 2017
This was referenced Oct 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants