Type checking in function _form_validate in form.inc

Created on 20 July 2011, about 13 years ago
Updated 11 August 2023, about 1 year ago

In the the value of is an of sometimes.
If the value is passed as an array, then also passed an array in the function (form.inc line 691), that results in an error:

mb_strlen() expects parameter 1 to be string, array given in .../drupal/includes/unicode.inc on line 404.

I suggest to add a check of value type in function _form_validate.
Below is a patch.

πŸ› Bug report
Status

Closed: works as designed

Version

7.0 ⚰️

Component
FormΒ  β†’

Last updated about 8 hours ago

Created by

πŸ‡΅πŸ‡±Poland azovsky

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States gbirch

    The patch should also check that the value is a string so as to prevent deprecation notices when NULL is passed to mb_strlen() by drupal_strlen().

  • Status changed to Closed: works as designed about 1 year ago
  • πŸ‡ΈπŸ‡°Slovakia poker10

    I would say that the problem mentioned in the IS can happen only if there is a field with #maxlength attribute, which expects an array (for example the select form element). However according to the Form API documentation, #maxlength is only allowed on these elements: machine_name, password, textfield. I do not think either of them could have a value of array. Therefore this is likely a programming error, which is not something the Drupal 7 core should sanitize.

    I am closing this as Works as designed. If someone can provide steps to reproduce which will work on the clean D7 install according to the Form API docs, then feel free to reopen this. Thanks!

Production build 0.71.5 2024