-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
Remove potential ending line break when using edebug() with LoggerInterface #3047
Conversation
src/SMTP.php
Outdated
@@ -280,6 +280,8 @@ protected function edebug($str, $level = 0) | |||
} | |||
//Is this a PSR-3 logger? | |||
if ($this->Debugoutput instanceof \Psr\Log\LoggerInterface) { | |||
//Remove ending line breaks potentialy added by calls to SMTP::client_send() | |||
$str = preg_replace('/[' . static::LE .']+$/', '', $str); |
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.
Instead of that static::LE
, this should use an explicit \r\n
as we are matching individual meta characters in a character class, not a literal string. static::LE
contains a literal "\r\n"
which represents actual CR and LF chars, not their meta-equivalents. Basically do what the other debug output options do.
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 would also fail the code style check, which requires spaces either side of string concat .
chars, but that's academic as you won't need to do concat with the above change.
src/SMTP.php
Outdated
@@ -280,6 +280,8 @@ protected function edebug($str, $level = 0) | |||
} | |||
//Is this a PSR-3 logger? | |||
if ($this->Debugoutput instanceof \Psr\Log\LoggerInterface) { | |||
//Remove ending line breaks potentialy added by calls to SMTP::client_send() | |||
$str = preg_replace('/[\r\n]+$/', '', $str); |
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.
Just wondering - could/should this be simplified to rtrim($str, "\r\n")
?
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.
my IDE was suggesting the same :-)
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.
Yep, that seems reasonable – and it could be used in the other cases as well. I expect it will be marginally faster, but I don't think optimising debugging output is really something to worry about!
This PR is for #3045.