@@ -370,9 +370,9 @@ protected function prepareAttributes(array $attributes)
370
370
371
371
if (! isset ($ this ->validGlobalAttributes [$ attribute ])
372
372
&& ! isset ($ this ->validTagAttributes [$ attribute ])
373
- && ' data- ' != substr ($ attribute , 0 , 5 )
374
- && ' aria- ' != substr ($ attribute , 0 , 5 )
375
- && ' x- ' != substr ($ attribute , 0 , 2 )
373
+ && 0 !== strpos ($ attribute , ' data- ' )
374
+ && 0 !== strpos ($ attribute , ' aria- ' )
375
+ && 0 !== strpos ($ attribute , ' x- ' )
376
376
) {
377
377
// Invalid attribute for the current tag
378
378
unset($ attributes [$ key ]);
@@ -434,13 +434,13 @@ protected function translateHtmlAttributeValue($key, $value)
434
434
return $ this ->getTranslator ()->translate ($ value , $ this ->getTranslatorTextDomain ());
435
435
} else {
436
436
foreach ($ this ->translatableAttributePrefixes as $ prefix ) {
437
- if (mb_substr ( $ key , 0 , mb_strlen ( $ prefix )) === $ prefix ) {
437
+ if (0 === mb_strpos ( $ key , $ prefix) ) {
438
438
// prefix matches => return translated $value
439
439
return $ this ->getTranslator ()->translate ($ value , $ this ->getTranslatorTextDomain ());
440
440
}
441
441
}
442
442
foreach (self ::$ defaultTranslatableHtmlAttributePrefixes as $ prefix ) {
443
- if (mb_substr ( $ key , 0 , mb_strlen ( $ prefix )) === $ prefix ) {
443
+ if (0 === mb_strpos ( $ key , $ prefix) ) {
444
444
// default prefix matches => return translated $value
445
445
return $ this ->getTranslator ()->translate ($ value , $ this ->getTranslatorTextDomain ());
446
446
}
0 commit comments