Commit graph

8 commits

Author SHA1 Message Date
marouanehassine
e80efda7c2 fix: return "Invalid data." instead of HTTP 500 on malformed v2 payloads
Under strict_types on PHP 8, malformed JSON API v2 payloads triggered
uncaught TypeErrors (HTTP 500) instead of the standard JSON error
response {"status":1,"message":"Invalid data."}:

- a non-numeric `v` reached `$data['v'] + 0` in Request::getData()
- a scalar `meta` reached `count($message['meta'])` in FormatV2::isValid()
- non-array adata[0] / non-string ct fields reached base64_decode(),
  strlen() and count() with the wrong types

Validate the types before the numeric coercion and before the
string/count operations, so all such inputs are rejected cleanly with
"Invalid data." instead of a fatal error. Both crashes are remotely
triggerable without authentication (availability only, no data exposure).

Adds FormatV2Test coverage for the malformed-type inputs.

Fixes #1883
2026-07-17 14:44:04 +02:00
El RIDO
629f263cf5
pass by reference, closes #858 2025-03-11 08:22:21 +01:00
El RIDO
cebc9acce6 enable strict types in PHP 2024-06-04 07:13:55 +02:00
El RIDO
6f90df9545
updating tests by dropping PHPunit 4.6 support 2020-10-10 12:08:58 +02:00
El RIDO
1e44902340
apply StyleCI patch 2019-05-10 21:45:34 +02:00
El RIDO
700f8a0ea7
made all php unit tests pass again 2019-05-10 07:55:39 +02:00
El RIDO
59569bf9fc
working on JsonApi tests 2019-05-08 22:11:21 +02:00
El RIDO
3338bd792e
implement version 2 format validation, changing ID checksum algorithm, resolves #49 2019-05-03 23:03:57 +02:00