Skip to content

Commit

Permalink
fix: add numeric check to parse to prevent dropdowns from being parsed (
Browse files Browse the repository at this point in the history
#976)

* hotfix(security|requests): add middleware that parses post fields

* fix: handle arrays

* fix: add "$this->" prefix to function calls

* fix(requests): prevent numeric value from being parsed

* chore(update): update version

---------

Co-authored-by: Mercury <[email protected]>
  • Loading branch information
ScuffedNewt and itinerare authored Jun 16, 2024
1 parent 426bbd1 commit f0aa1f8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app/Http/Middleware/ParsePostRequestFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public function handle(Request $request, Closure $next) {
if (is_array($value)) {
$parsedFields[$key] = $this->parseArray($value, $strippedFields);
} else {
if (is_numeric($value)) {
continue;
}

if (in_array($key, $strippedFields)) { // we strip these since parse() doesn't remove HTML tags
$parsedFields[$key] = parse(strip_tags($value));
} else {
Expand All @@ -47,6 +51,10 @@ public function handle(Request $request, Closure $next) {
*/
private function parseArray(array $array, array $strippedFields) : array {
foreach ($array as $key => $value) {
if (is_numeric($value)) {
continue;
}

if (is_array($value)) {
$array[$key] = $this->parseArray($value, $strippedFields);
} else {
Expand Down
2 changes: 1 addition & 1 deletion config/lorekeeper/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
| Do not change this value!
|
*/
'version' => '2.1.6',
'version' => '2.1.7',

/*
|--------------------------------------------------------------------------
Expand Down

0 comments on commit f0aa1f8

Please sign in to comment.