Re: max_input_vars trigger detection
| From: | Côme Chilliet | Date: | Wed, 13 May 2020 09:47:55 +0000 |
| Subject: | Re: max_input_vars trigger detection | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-110150@lists.php.net to get a copy of this message | ||
Le Sun, 10 May 2020 13:34:12 +0100,
Craig Duncan <php@duncanc.co.uk> a écrit :
> Although not particularly elegant, and it does require you to
> reject
> requests that hit but don't exceed the limit, I've used this approach
> before:
>
> $max = ini_get("max_input_vars") - 1;
> $check = count($_REQUEST);
> if ($check > $max) {
> throw new RequestException("Request is too large, only {$max}
> input variables are permitted");
> }
This is not even correct if I’m not mistaken, as max_input_vars applies
independently to GET, POST and COOKIE as I understand it. Here with
max_input_vars/2 in GET and POST your exception would throw while the
limit was not hit.
I know this is a corner case, but it’s just to illustrate it’s hard to
detect whether this limit was hit and it would be better in my opinion
to have a clean way in core.