Skip to content

Commit 6a8e7e2

Browse files
committed
Updated Backend url checker to use RFC3986 instead of RFC2396 which was rejecting valid names such as foo_plex.domain.com
1 parent cb5d28c commit 6a8e7e2

File tree

6 files changed

+14
-8
lines changed

6 files changed

+14
-8
lines changed

src/Backends/Jellyfin/JellyfinManage.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ public function manage(array $backend, array $opts = []): array
3737
);
3838

3939
$question->setValidator(function ($answer) {
40-
if (!filter_var($answer, FILTER_VALIDATE_URL)) {
41-
throw new RuntimeException('Invalid backend URL was given.');
40+
$host = parse_url($answer, PHP_URL_HOST);
41+
if (false === is_string($answer)) {
42+
throw new RuntimeException(
43+
'Invalid backend URL was given. Expecting something like http://example.com:8096/'
44+
);
4245
}
4346
return $answer;
4447
});

src/Backends/Plex/PlexManage.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,11 @@ public function manage(array $backend, array $opts = []): array
156156
);
157157
158158
$question->setValidator(function ($answer) {
159-
if (!filter_var($answer, FILTER_VALIDATE_URL)) {
160-
throw new RuntimeException('Invalid URL was selected/given.');
159+
$host = parse_url($answer, PHP_URL_HOST);
160+
if (false === is_string($answer)) {
161+
throw new RuntimeException(
162+
'Invalid URL was selected/given. Expecting something like http://plex:32400.'
163+
);
161164
}
162165
return $answer;
163166
});

src/Commands/State/BackupCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ protected function process(InputInterface $input, OutputInterface $output): int
177177
continue;
178178
}
179179

180-
if (null === ($url = ag($backend, 'url')) || false === filter_var($url, FILTER_VALIDATE_URL)) {
180+
if (null === ($url = ag($backend, 'url')) || true !== is_string(parse_url($url, PHP_URL_HOST))) {
181181
$this->logger->error('SYSTEM: Ignoring [{backend}] because of invalid URL.', [
182182
'backend' => $backendName,
183183
'url' => $url ?? 'None',

src/Commands/State/ExportCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ protected function process(InputInterface $input, OutputInterface $output): int
164164
continue;
165165
}
166166

167-
if (null === ($url = ag($backend, 'url')) || false === filter_var($url, FILTER_VALIDATE_URL)) {
167+
if (null === ($url = ag($backend, 'url')) || true !== is_string(parse_url($url, PHP_URL_HOST))) {
168168
$this->logger->error(
169169
sprintf('%s: Backend does not have valid url.', $backendName),
170170
['url' => $url ?? 'None']

src/Commands/State/ImportCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ protected function process(InputInterface $input, OutputInterface $output): int
298298
continue;
299299
}
300300

301-
if (null === ($url = ag($backend, 'url')) || false === filter_var($url, FILTER_VALIDATE_URL)) {
301+
if (null === ($url = ag($backend, 'url')) || true !== is_string(parse_url($url, PHP_URL_HOST))) {
302302
$this->logger->error('SYSTEM: Ignoring [{backend}] because of invalid URL.', [
303303
'backend' => $backendName,
304304
'url' => $url ?? 'None',

src/Commands/State/PushCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ protected function process(InputInterface $input): int
133133
continue;
134134
}
135135

136-
if (null === ($url = ag($backend, 'url')) || false === filter_var($url, FILTER_VALIDATE_URL)) {
136+
if (null === ($url = ag($backend, 'url')) || true !== is_string(parse_url($url, PHP_URL_HOST))) {
137137
$this->logger->error('SYSTEM: [{backend}] Invalid url.', [
138138
'backend' => $backendName,
139139
'url' => $url ?? 'None',

0 commit comments

Comments
 (0)