namespace wcf\data\package\update\server;
+use Laminas\Diactoros\Uri;
use wcf\data\DatabaseObject;
use wcf\system\cache\builder\PackageUpdateCacheBuilder;
-use wcf\system\io\RemoteFile;
use wcf\system\Regex;
use wcf\system\registry\RegistryHandler;
use wcf\system\WCF;
/**
* Returns the list endpoint for package servers.
*
- * @param bool $forceHTTP
* @return string
*/
- public function getListURL($forceHTTP = false)
+ public function getListURL()
{
- if ($this->apiVersion == '2.0') {
- return $this->serverURL;
- }
+ $url = new Uri($this->serverURL);
- $serverURL = FileUtil::addTrailingSlash($this->serverURL) . 'list/' . WCF::getLanguage()->getFixedLanguageCode() . '.xml';
+ if ($url->getHost() !== 'localhost') {
+ $url = $url->withScheme('https');
+ }
- $metaData = $this->getMetaData();
- if ($forceHTTP || !RemoteFile::supportsSSL() || !$metaData['ssl']) {
- return \preg_replace('~^https://~', 'http://', $serverURL);
+ if ($this->apiVersion == '2.0') {
+ return (string)$url;
}
- return \preg_replace('~^http://~', 'https://', $serverURL);
+ return FileUtil::addTrailingSlash((string)$url) . 'list/' . WCF::getLanguage()->getFixedLanguageCode() . '.xml';
}
/**
*/
public function getDownloadURL()
{
- if ($this->apiVersion == '2.0') {
- return $this->serverURL;
- }
+ $url = new Uri($this->serverURL);
- $metaData = $this->getMetaData();
- if (!RemoteFile::supportsSSL() || !$metaData['ssl']) {
- return \preg_replace('~^https://~', 'http://', $this->serverURL);
+ if ($url->getHost() !== 'localhost') {
+ $url = $url->withScheme('https');
}
- return \preg_replace('~^http://~', 'https://', $this->serverURL);
+ return (string)$url;
}
/**
}
/**
- * Returns true if a request to this server would make use of a secure connection.
- *
- * @return bool
+ * @deprecated 5.6 This method always returns true. Package servers must use TLS.
*/
public function attemptSecureConnection()
{
- if ($this->apiVersion == '2.0') {
- return false;
- }
-
- $metaData = $this->getMetaData();
- if (RemoteFile::supportsSSL() && $metaData['ssl']) {
- return true;
- }
-
- return false;
+ return true;
}
/**