MDL-51242 messageinbound: Guess the port from hostspec

Existing language strings for the host component suggest that the host can
be provided in the format hostname:port, but we previously did not support
this.

This patch explodes the string based on the colon character and assumes
that if there are two parts, that they are in the format hostname:port.

Note: This does not attempt to deal with full host specifications (e.g.
protocol://hostname:port), as this is beyond the scope of this change.
This commit is contained in:
Andrew Nicols 2016-07-05 14:50:25 +08:00
parent ac8d6cff54
commit 275480a0de

View File

@ -103,6 +103,15 @@ class manager {
'debug' => empty($CFG->debugimap) ? null : fopen('php://stderr', 'w'),
);
if (strpos($configuration['hostspec'], ':')) {
$hostdata = explode(':', $configuration['hostspec']);
if (count($hostdata) === 2) {
// A hostname in the format hostname:port has been provided.
$configuration['hostspec'] = $hostdata[0];
$configuration['port'] = $hostdata[1];
}
}
$this->client = new \Horde_Imap_Client_Socket($configuration);
try {