';
self::assertSame($input, lazyimg($input));
} finally {
ini_set('pcre.backtrack_limit', $limit);
}
}
public function test_lazyimg_overlong_tags_are_skipped(): void {
// Tags with more than 1000 characters of attributes are expected to be skipped (eager loading)
$overlong = str_repeat('a', 1001);
self::assertSame('
', lazyimg('
'));
self::assertSame('',
lazyimg(''));
// Under the limit, the work is still bounded and lazy loading is applied
$atLimit = str_repeat('a', 980); // 6 + 980 + 13 = 999 characters of attributes
$placeholder = Minz_Url::display('/themes/icons/grey.gif');
self::assertSame('
',
lazyimg('
'));
self::assertSame('',
lazyimg(''));
}
/** @return array */
public static function provideLazyimg(): array {
$placeholder = Minz_Url::display('/themes/icons/grey.gif');
return [
'ordinary image' => ['
', '
'],
'multiple tags' => ['
',
'
'],
'video poster' => ['', ''],
'video poster with other attributes' => ['',
''],
'video without poster untouched' => ['', ''],
'track element' => ['