Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion php/class-delivery.php
Original file line number Diff line number Diff line change
Expand Up @@ -1566,7 +1566,10 @@ public function parse_element( $element, $content = '' ) {

return null;
}
$raw_url = 'source' === $tag_element['tag'] && ! empty( $attributes['srcset'] ) ? $attributes['srcset'] : $attributes['src'];
$raw_url = 'source' === $tag_element['tag'] && ! empty( $attributes['srcset'] ) ? $attributes['srcset'] : ( $attributes['src'] ?? '' );
if ( '' === $raw_url ) {
return null;
}
$url = $this->maybe_unsize_url( Utils::clean_url( $this->sanitize_url( $raw_url ) ) );
$tag_element['base_url'] = $url;
// Track back the found URL.
Expand Down Expand Up @@ -1943,6 +1946,11 @@ protected function set_usability( $item, $auto_sync = null ) {
*/
protected function sanitize_url( $url ) {

// Bail early on empty or non-string URLs.
if ( ! is_string( $url ) || '' === $url ) {
return null;
}

// Catch mixed URLs.
if ( 5 < strlen( $url ) && false !== strpos( $url, 'https://', 5 ) ) {
$url = substr( $url, strpos( $url, 'https://', 5 ) );
Expand Down
Loading