Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
77c1c41
feat: add parameter type `multi-list`
papaj-na-wrotkach Feb 6, 2026
a6cd0b6
fix: fix parameter validation for arrays
papaj-na-wrotkach Feb 6, 2026
c4f1880
test: validate `BridgeCard::getListInput` method for `multi-list`
papaj-na-wrotkach Feb 6, 2026
d573a65
test: handle `multi-list` parameter type in `BridgeImplementationTest`
papaj-na-wrotkach Feb 6, 2026
b6cace4
test: add tests for `multi-list` parameter type in `ParameterValidato…
papaj-na-wrotkach Feb 6, 2026
564420d
test: fix errors in tests
papaj-na-wrotkach Feb 7, 2026
4ac27cd
fix: handle `defaultValue` properly for `multi-list`
papaj-na-wrotkach Feb 7, 2026
6d2427d
fix: clarify the description in the docblock
papaj-na-wrotkach Feb 7, 2026
044d896
style: add braces to comply with PSR-12
papaj-na-wrotkach Feb 8, 2026
f1b3392
fix(ui): make `multi-list` parameters displayed correctly
papaj-na-wrotkach Feb 8, 2026
ad1738b
fix: make backported array functions behave correctly
papaj-na-wrotkach Feb 8, 2026
d84f7f2
fix: validate the parameter type correctly
papaj-na-wrotkach Feb 8, 2026
9b7cddf
fixup! fix: validate the parameter type correctly
papaj-na-wrotkach Feb 8, 2026
79ceb94
fixup! fix(ui): make `multi-list` parameters displayed correctly
papaj-na-wrotkach Feb 8, 2026
1f871e2
fixup! style: add braces to comply with PSR-12
papaj-na-wrotkach Feb 8, 2026
14f6329
Merge branch 'master' into feat/mult-list-parameter
papaj-na-wrotkach Feb 9, 2026
4843b0b
style: fix line length
papaj-na-wrotkach Feb 9, 2026
735b5d5
feat: support for scalar `defaultValue` for `multi-list`
papaj-na-wrotkach Feb 9, 2026
4c41ad5
fixup! feat: support for scalar `defaultValue` for `multi-list`
papaj-na-wrotkach Feb 10, 2026
b2ebe01
fix: detect empty values inside `getListInput`
papaj-na-wrotkach Feb 10, 2026
8b7bc26
Merge branch 'RSS-Bridge:master' into feat/mult-list-parameter
papaj-na-wrotkach Feb 10, 2026
7a4b7bf
Merge branch 'master' into feat/mult-list-parameter
papaj-na-wrotkach Feb 10, 2026
ea6ffcd
style: fix line exceeding character limit
papaj-na-wrotkach Feb 10, 2026
177ae0c
fix: properly handle empty default value
papaj-na-wrotkach Feb 11, 2026
e784e32
fix: do not access `defaultValue` if there are no values
papaj-na-wrotkach Feb 11, 2026
f57ce19
test: add test for multiple default values
papaj-na-wrotkach Feb 11, 2026
3de2325
Merge branch 'master' into feat/mult-list-parameter
papaj-na-wrotkach Feb 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/BridgeCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ private static function renderForm(
$form .= self::getNumberInput($inputEntry, $idArg, $id);
} elseif ($inputEntry['type'] === 'list') {
$form .= self::getListInput($inputEntry, $idArg, $id) . "\n";
} elseif ($inputEntry['type'] === 'multi-list') {
$form .= self::getListInput($inputEntry, $idArg, $id, true) . "\n";
} elseif ($inputEntry['type'] === 'checkbox') {
$form .= self::getCheckboxInput($inputEntry, $idArg, $id);
} else {
Expand Down Expand Up @@ -196,7 +198,7 @@ public static function getNumberInput(array $entry, string $id, string $name): s
return sprintf('<input %s id="%s" type="number" value="%s" placeholder="%s" name="%s" />' . "\n", $attributes, $id, $defaultValue, $exampleValue, $name);
}

public static function getListInput(array $entry, string $id, string $name): string
public static function getListInput(array $entry, string $id, string $name, bool $isMulti = false): string
{
$required = $entry['required'] ?? null;
if ($required) {
Expand All @@ -205,7 +207,7 @@ public static function getListInput(array $entry, string $id, string $name): str
}

$attributes = self::getInputAttributes($entry);
$list = sprintf('<select %s id="%s" name="%s" >' . "\n", $attributes, $id, $name);
$list = sprintf('<select %s id="%s" name="%s" %s>' . "\n", $attributes, $id, $name . ($isMulti ? '[]' : ''), $isMulti ? 'multiple ' : '');

foreach ($entry['values'] as $name => $value) {
if (is_array($value)) {
Expand Down
4 changes: 4 additions & 0 deletions lib/ParameterValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public function validateInput(array &$input, $contexts): array
case 'list':
$input[$name] = $this->validateListValue($value, $contextParameters[$name]['values']);
break;
case 'multi-list':
//TODO: Maybe move the array checking and looping through all of the values to another method?
$input[$name] = is_array($value) ? array_map(fn($v) => $this->validateListValue($v, $contextParameters[$name]['values']), $value) : null;
break;
default:
case 'text':
if (isset($contextParameters[$name]['pattern'])) {
Expand Down
14 changes: 8 additions & 6 deletions middlewares/SecurityMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
declare(strict_types=1);

/**
* Make sure that only strings are allowed in GET parameters
* Make sure that only strings and arrays are allowed in GET parameters
*/
class SecurityMiddleware implements Middleware
{
public function __invoke(Request $request, $next): Response
{
foreach ($request->toArray() as $key => $value) {
if (!is_string($value)) {
return new Response(render(__DIR__ . '/../templates/error.html.php', [
'message' => "Query parameter \"$key\" is not a string.",
]), 400);
}
//TODO: Maybe stricter checking for arrays?
// Not required technically because the values are properly checked
// in ParameterValidator, so basic check like this should be OK.
if (is_string($value) || (is_array($value) && !in_array(fn($v) => !is_string($v), $value))) continue;
return new Response(render(__DIR__ . '/../templates/error.html.php', [
'message' => "Query parameter \"$key\" is not a string.",
]), 400);
}
return $next($request);
}
Expand Down
Loading