Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
afi
zf
Commits
e8e89585
Commit
e8e89585
authored
Aug 02, 2018
by
efalcy
Browse files
hotline #77270 : add crypto stream methods for compatibility with php > 5.6 for mail
parent
7fed0bfe
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
30 deletions
+78
-30
library/Zend/Mail/Protocol/Imap.php
library/Zend/Mail/Protocol/Imap.php
+29
-12
library/Zend/Mail/Protocol/Pop3.php
library/Zend/Mail/Protocol/Pop3.php
+24
-9
library/Zend/Mail/Protocol/Smtp.php
library/Zend/Mail/Protocol/Smtp.php
+25
-9
No files found.
library/Zend/Mail/Protocol/Imap.php
View file @
e8e89585
...
...
@@ -11,7 +11,7 @@
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
*
* @category Zend
* @package Zend_Mail
* @subpackage Protocol
...
...
@@ -104,17 +104,34 @@ class Zend_Mail_Protocol_Imap
if
(
$ssl
===
'TLS'
)
{
$result
=
$this
->
requestAndResponse
(
'STARTTLS'
);
$result
=
$result
&&
stream_socket_enable_crypto
(
$this
->
_socket
,
true
,
STREAM_CRYPTO_METHOD_TLS_CLIENT
);
if
(
!
$result
)
{
/**
* @see Zend_Mail_Protocol_Exception
*/
require_once
'Zend/Mail/Protocol/Exception.php'
;
throw
new
Zend_Mail_Protocol_Exception
(
'cannot enable TLS'
);
}
$result
=
$result
&&
$this
->
_connectViaTLS
();
}
}
protected
function
_connectViaTLS
()
{
$success
=
false
;
$modes
=
defined
(
'STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT'
)
?
array
(
STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT
,
STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT
,
STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT
,
)
:
array
(
STREAM_CRYPTO_METHOD_TLS_CLIENT
,
);
foreach
(
$modes
as
$mode
)
{
$success
=
stream_socket_enable_crypto
(
$this
->
_socket
,
true
,
$mode
);
if
(
$success
)
return
true
;
}
require_once
'Zend/Mail/Protocol/Exception.php'
;
throw
new
Zend_Mail_Protocol_Exception
(
'Unable to connect via TLS'
);
}
/**
* get the next line from socket with error checking, but nothing else
*
...
...
@@ -189,8 +206,8 @@ class Zend_Mail_Protocol_Imap
"foo" baz {3}<NL>bar ("f\\\"oo" bar)
would be returned as:
array('foo', 'baz', 'bar', array('f\\\"oo', 'bar'));
// TODO: add handling of '[' and ']' to parser for easier handling of response text
// TODO: add handling of '[' and ']' to parser for easier handling of response text
*/
// replace any trailling <NL> including spaces with a single space
$line
=
rtrim
(
$line
)
.
' '
;
...
...
@@ -818,7 +835,7 @@ class Zend_Mail_Protocol_Imap
if
(
!
$response
)
{
return
$response
;
}
foreach
(
$response
as
$ids
)
{
if
(
$ids
[
0
]
==
'SEARCH'
)
{
array_shift
(
$ids
);
...
...
library/Zend/Mail/Protocol/Pop3.php
View file @
e8e89585
...
...
@@ -11,7 +11,7 @@
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
*
* @category Zend
* @package Zend_Mail
* @subpackage Protocol
...
...
@@ -114,19 +114,34 @@ class Zend_Mail_Protocol_Pop3
if
(
$ssl
===
'TLS'
)
{
$this
->
request
(
'STLS'
);
$result
=
stream_socket_enable_crypto
(
$this
->
_socket
,
true
,
STREAM_CRYPTO_METHOD_TLS_CLIENT
);
if
(
!
$result
)
{
/**
* @see Zend_Mail_Protocol_Exception
*/
require_once
'Zend/Mail/Protocol/Exception.php'
;
throw
new
Zend_Mail_Protocol_Exception
(
'cannot enable TLS'
);
}
$result
=
$this
->
_connectViaTLS
();
}
return
$welcome
;
}
protected
function
_connectViaTLS
()
{
$success
=
false
;
$modes
=
defined
(
'STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT'
)
?
array
(
STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT
,
STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT
,
STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT
,
)
:
array
(
STREAM_CRYPTO_METHOD_TLS_CLIENT
,
);
foreach
(
$modes
as
$mode
)
{
$success
=
stream_socket_enable_crypto
(
$this
->
_socket
,
true
,
$mode
);
if
(
$success
)
return
true
;
}
require_once
'Zend/Mail/Protocol/Exception.php'
;
throw
new
Zend_Mail_Protocol_Exception
(
'Unable to connect via TLS'
);
}
/**
* Send a request
...
...
library/Zend/Mail/Protocol/Smtp.php
View file @
e8e89585
...
...
@@ -12,7 +12,7 @@
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
*
* @category Zend
* @package Zend_Mail
* @subpackage Protocol
...
...
@@ -38,7 +38,7 @@ require_once 'Zend/Mail/Protocol/Abstract.php';
* Smtp implementation of Zend_Mail_Protocol_Abstract
*
* Minimum implementation according to RFC2821: EHLO, MAIL FROM, RCPT TO, DATA, RSET, NOOP, QUIT
*
*
* @category Zend
* @package Zend_Mail
* @subpackage Protocol
...
...
@@ -203,13 +203,7 @@ class Zend_Mail_Protocol_Smtp extends Zend_Mail_Protocol_Abstract
if
(
$this
->
_secure
==
'tls'
)
{
$this
->
_send
(
'STARTTLS'
);
$this
->
_expect
(
220
,
180
);
if
(
!
stream_socket_enable_crypto
(
$this
->
_socket
,
true
,
STREAM_CRYPTO_METHOD_TLS_CLIENT
))
{
/**
* @see Zend_Mail_Protocol_Exception
*/
require_once
'Zend/Mail/Protocol/Exception.php'
;
throw
new
Zend_Mail_Protocol_Exception
(
'Unable to connect via TLS'
);
}
$this
->
_connectViaTLS
();
$this
->
_ehlo
(
$host
);
}
...
...
@@ -218,6 +212,28 @@ class Zend_Mail_Protocol_Smtp extends Zend_Mail_Protocol_Abstract
}
protected
function
_connectViaTLS
()
{
$success
=
false
;
$modes
=
defined
(
'STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT'
)
?
array
(
STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT
,
STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT
,
STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT
,
)
:
array
(
STREAM_CRYPTO_METHOD_TLS_CLIENT
,
);
foreach
(
$modes
as
$mode
)
{
$success
=
stream_socket_enable_crypto
(
$this
->
_socket
,
true
,
$mode
);
if
(
$success
)
break
;
}
require_once
'Zend/Mail/Protocol/Exception.php'
;
throw
new
Zend_Mail_Protocol_Exception
(
'Unable to connect via TLS'
);
}
/**
* Send EHLO or HELO depending on capabilities of smtp host
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment