/** * validates a subscription's url * @param ISubscription $subscription * @throws \OCA\Calendar\Backend\Exception */ protected function validateSubscriptionUrl(ISubscription &$subscription) { $url = $subscription->getUrl(); $parsed = parse_url($url); if (!$parsed) { throw new BackendUtils\Exception('URL not processable'); } if (!isset($parsed['scheme'])) { //TODO - try to use https first $newUrl = 'http://'; $newUrl .= $url; $subscription->setUrl($newUrl); $parsed['scheme'] = 'http'; } if ($parsed['scheme'] === 'webcal') { $newUrl = preg_replace("/^webcal:/i", "http:", $url); $subscription->setUrl($newUrl); $parsed['scheme'] = 'http'; } if ($parsed['scheme'] !== 'http' && $parsed['scheme'] !== 'https') { throw new BackendUtils\Exception('Protocol not supported'); } }