forked from corowne/lorekeeper
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/v3.0.0' of https://github.com/corowne/lorekeeper …
…into v3/world-expansion
- Loading branch information
Showing
46 changed files
with
687 additions
and
386 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
namespace App\Http\Middleware; | ||
|
||
use Closure; | ||
use Illuminate\Http\Request; | ||
|
||
class ParsePostRequestFields { | ||
/** | ||
* Handle an incoming request. | ||
* | ||
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\RedirectResponse|\Illuminate\Http\Response) $next | ||
* | ||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response | ||
*/ | ||
public function handle(Request $request, Closure $next) { | ||
if ($request->isMethod('post')) { | ||
$excludedFields = ['_token', 'password', 'email', 'description', 'text']; | ||
$strippedFields = ['name', 'title']; | ||
|
||
$parsedFields = []; | ||
foreach ($request->except($excludedFields) as $key => $value) { | ||
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 { | ||
$parsedFields[$key] = parse($value); | ||
} | ||
} | ||
} | ||
|
||
$request->merge($parsedFields); | ||
} | ||
|
||
return $next($request); | ||
} | ||
|
||
/** | ||
* Recursively parse array values. | ||
*/ | ||
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 { | ||
if (in_array($key, $strippedFields)) { | ||
$array[$key] = parse(strip_tags($value)); | ||
} else { | ||
$array[$key] = parse($value); | ||
} | ||
} | ||
} | ||
|
||
return $array; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.