FU: Accept charset argument in JSON request content-type header

This commit is contained in:
Yorhel 2025-04-24 10:50:50 +02:00
parent ab168bd952
commit 4833456898

2
FU.pm
View file

@ -689,7 +689,7 @@ sub cookie {
sub json {
shift;
fu->error(400, "Invalid content type for json") if (fu->header('content-type')||'') ne 'application/json';
fu->error(400, "Invalid content type for json") if (fu->header('content-type')||'') !~ m{^application/json(?:;\s*charset=utf-?8)?$}i;
return FU::Util::utf8_decode(my $x = $FU::REQ->{body}) if !@_;
$FU::REQ->{json} ||= eval {
FU::Util::json_parse($FU::REQ->{body}, utf8 => 1)