Skip to content

Commit

Permalink
MBS-8003: Greenify pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
PhMemmel committed Oct 20, 2023
1 parent d7966c4 commit 93d0d5c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
4 changes: 3 additions & 1 deletion classes/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,9 @@ public static function sanitize_json_string(string $jsonstring): string {
foreach ($json as $key => $value) {
unset($json[$key]);
$key = clean_param(clean_param($key, PARAM_CLEANHTML), PARAM_NOTAGS);
$json[$key] = is_array($value) ? clean_param_array($value, PARAM_CLEANHTML, true) : clean_param($value, PARAM_CLEANHTML);
$json[$key] = is_array($value)
? clean_param_array($value, PARAM_CLEANHTML, true)
: clean_param($value, PARAM_CLEANHTML);
}
return json_encode($json);
}
Expand Down
18 changes: 9 additions & 9 deletions tests/boardmanager_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,9 @@ public function test_can_user_manage_specific_card() {
/**
* Tests the json sanitization function.
*
* @dataProvider test_sanitize_json_string_provider
* @param $jsonstring string the json string to sanitize
* @param $sanitized string the expected sanitized json string
* @dataProvider sanitize_json_string_provider
* @param string $jsonstring the json string to sanitize
* @param string $sanitized the expected sanitized json string
* @return void
*/
public function test_sanitize_json_string(string $jsonstring, string $sanitized): void {
Expand All @@ -336,24 +336,24 @@ public function test_sanitize_json_string(string $jsonstring, string $sanitized)
*
* @return array[] containing the keys 'json' and 'expected'
*/
public function test_sanitize_json_string_provider(): array {
public static function sanitize_json_string_provider(): array {
return [
[
'json' => '{"test": "<b>bad html</b><script>console.log(\"bla\")</script>"}',
'expected' => '{"test":"<b>bad html<\/b>"}'
'expected' => '{"test":"<b>bad html<\/b>"}',
],
[
'json' => '{"test": "<b>good html</b>"}',
'expected' => '{"test":"<b>good html<\/b>"}'
'expected' => '{"test":"<b>good html<\/b>"}',
],
[
'json' => '{"test": "<b>good html</b>","anotherkey": [{"nestedkey":"<script>console.log(\"bla\");</script>"}]}',
'expected' => '{"test":"<b>good html<\/b>","anotherkey":[{"nestedkey":""}]}'
'expected' => '{"test":"<b>good html<\/b>","anotherkey":[{"nestedkey":""}]}',
],
[
'json' => '{"te<script>console.log(\"bla\");</script>st": "<b>good html</b>"}',
'expected' => '{"test":"<b>good html<\/b>"}'
]
'expected' => '{"test":"<b>good html<\/b>"}',
],
];
}
}

0 comments on commit 93d0d5c

Please sign in to comment.