mirror of
git://develop.git.wordpress.org/
synced 2025-01-29 18:48:18 +01:00
Script Loader: Do not normalize absolute paths in inline block styles CSS.
`_wp_normalize_relative_css_links()` used to normalize all non-absolute URLs regardless of whether it's a relative path or an absolute path. The normalization should only happen for relative paths (paths without a leading `/`) and not for absolute paths. Reference: [https://www.rfc-editor.org/rfc/rfc1808#section-4 RFC 1808, Section 4, Step 4]. Follow-up to [52036], [52695], [52754], [55658], [55669]. Props scholdstrom. Fixes #61909. git-svn-id: https://develop.svn.wordpress.org/trunk@58932 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
0687800e09
commit
4905653882
@ -3056,7 +3056,7 @@ function _wp_normalize_relative_css_links( $css, $stylesheet_url ) {
|
||||
if (
|
||||
str_starts_with( $url, 'http:' ) ||
|
||||
str_starts_with( $url, 'https:' ) ||
|
||||
str_starts_with( $url, '//' ) ||
|
||||
str_starts_with( $url, '/' ) ||
|
||||
str_starts_with( $url, '#' ) ||
|
||||
str_starts_with( $url, 'data:' )
|
||||
) {
|
||||
|
@ -228,6 +228,10 @@ class Tests_Dependencies_Styles extends WP_UnitTestCase {
|
||||
'css' => 'p {background-image: url(\'../image1.jpg\');}',
|
||||
'expected' => 'p {background-image: url(\'/wp-content/themes/test/../image1.jpg\');}',
|
||||
),
|
||||
'URLs with absolute path, shouldn\'t change' => array(
|
||||
'css' => 'p {background:url( "/image0.svg" );}',
|
||||
'expected' => 'p {background:url( "/image0.svg" );}',
|
||||
),
|
||||
'External URLs, shouldn\'t change' => array(
|
||||
'css' => 'p {background-image: url(\'http://foo.com/image2.png\');}',
|
||||
'expected' => 'p {background-image: url(\'http://foo.com/image2.png\');}',
|
||||
|
Loading…
x
Reference in New Issue
Block a user