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
Fixed issue #7579 on the 2.7 branch #7766
Conversation
Looks good to me. |
@dereuromark Thanks for the quick reply! |
@@ -129,8 +129,12 @@ public function connect() { | |||
$this->disconnect(); | |||
} | |||
|
|||
$hasProtocol = strpos($this->config['host'], '://') !== false; |
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.
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.
You will have to ask @markstory .
I could think of performance reasons, even though it would be very minor - and only relevant for a lot of loop calls.
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.
With parse_url
the relevant code would look like this:
$urlParts = parse_url($this->config['host']);
$this->config['host'] = $urlParts['host'];
if (isset($urlParts['scheme'])) {
$this->config['protocol'] = $urlParts['scheme'];
}
Maybe it is subject to taste, but to me this looks cleaner. Thanks for the reminder @AD7six
Update:
The code wouldn't work if the host doesn't contain the protocol part, for example $this->config['host'] = 'www.cakephp.org'
. We need to check if 'host' exists in the parse result:
$urlParts = parse_url($this->config['host']);
if (isset($urlParts['host'])) {
$this->config['host'] = $urlParts['host'];
}
if (isset($urlParts['scheme'])) {
$this->config['protocol'] = $urlParts['scheme'];
}
I'm not quite sure if parse_url
is still a better solution considering this. Please give some advise, @dereuromark @AD7six . Thanks!
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 used string slicing because I didn't think of parse_url() when I wrote the code. It looks like parse_url() would be more complicated though.
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.
Question answered 👍
The hopping from scheme to protocol to scheme is a bit awkward - but not worth worrying about.
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.
Then I'll leave the code as it is now. 😈
Fixed issue incorrect SNI validation when host name contains protocol for SmtpTransport.
Issue #7579 also exists on the 2.7 branch. On master branch, it was fixed by PR #7581. The same code also fix this issue for the 2.7 branch.