FluidTYPO3/vhs

BUG: PHP Warning: Uninitialized string offset 1 in ViewHelpers/Random/StringViewHelper.php line 71

ogrosko opened this issue · 3 comments

Calling following VH

{v:random.string(minimumLength: 8, maximumLength: 16, characters: '*')}

results in PHP warning PHP Warning: Uninitialized string offset 1 in ViewHelpers/Random/StringViewHelper.php line 71

TYPO3: 12.4.19
VHS: 7.0.6

Characters cannot be * since that is treated literally as a list of 1 character with a value of *. If you want the characters list to be something other than 0123456789abcdef (resulting in base16-safe values) you'll need to specify the explicit list, e.g. adding the rest of the alphabetic characters and any special characters like hyphens or underscores to the list. If you want to use the default base16-safe character list simply omit the characters argument.

The ViewHelper could report this as a specific exception (a character list of 1 character makes no sense since this is the same as hardcoding a string consisting of a single character to the desired length) - but the usage itself is not a valid use case.

@NamelessCoder understand thx for an explanation. We've used workarround and set following characters: '***'

That's a good, quick and simple workaround :)