Issue Bug Closed

#98175Option fixAttrib.[attribute].prefixRelPathWith of HTMLParser throws warning since PHP 8

Hannes Bochmann 08/19/22, 08:28 updated 12/06/22, 21:43

Description

If fixAttrib.[attribute].prefixRelPathWith is configured for let’s say a image, there might be a warning like “ PHP Warning: Undefined array key “scheme” in …/typo3/sysext/core/Classes/Html/HtmlParser.php line 574 “

If you look at the code it’s obvious.

if ($params['prefixRelPathWith'] ?? false) {
    $urlParts = parse_url($tagAttrib[0][$attr]);
    if (!$urlParts['scheme'] && $urlParts['path'][0] !== '/') {
        // If it is NOT an absolute URL (by http: or starting "/")
        $tagAttrib[0][$attr] = $params['prefixRelPathWith'] . $tagAttrib[0][$attr];
    }
}

If prefixRelPathWith is set the given URL will likely be a local one without a scheme leading to said warning.

Reviews 2