Changeset 60734
- Timestamp:
- 09/12/2025 10:03:25 PM (2 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
src/wp-includes/formatting.php (modified) (2 diffs)
-
tests/phpunit/tests/formatting/escUrl.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/formatting.php
r60726 r60734 4643 4643 * 4644 4644 * @since 2.8.0 4645 * @since 6.9.0 Prepends `https://` to the URL if it does not already contain a scheme 4646 * and the first item in `$protocols` is 'https'. 4645 4647 * 4646 4648 * @param string $url The URL to be cleaned. … … 4675 4677 * If the URL doesn't appear to contain a scheme, we presume 4676 4678 * it needs http:// prepended (unless it's a relative link 4677 * starting with /, # or ?, or a PHP file). 4679 * starting with /, # or ?, or a PHP file). If the first item 4680 * in $protocols is 'https', then https:// is prepended. 4678 4681 */ 4679 4682 if ( ! str_contains( $url, ':' ) && ! in_array( $url[0], array( '/', '#', '?' ), true ) && 4680 4683 ! preg_match( '/^[a-z0-9-]+?\.php/i', $url ) 4681 4684 ) { 4682 $url = 'http://' . $url; 4685 $scheme = ( is_array( $protocols ) && 'https' === array_first( $protocols ) ) ? 'https://' : 'http://'; 4686 $url = $scheme . $url; 4683 4687 } 4684 4688 -
trunk/tests/phpunit/tests/formatting/escUrl.php
r60251 r60734 91 91 92 92 /** 93 * @ticket 23605 94 * @ticket 52886 95 * 93 96 * @covers ::wp_allowed_protocols 94 97 */ … … 97 100 $this->assertSame( '', esc_url( 'nasty://example.com/' ) ); 98 101 $this->assertSame( 99 ' ',102 'https://example.com', 100 103 esc_url( 101 104 'example.com', 102 105 array( 106 'https', 107 ) 108 ) 109 ); 110 $this->assertSame( 111 'http://example.com', 112 esc_url( 113 'example.com', 114 array( 115 'http', 116 ) 117 ) 118 ); 119 $this->assertSame( 120 'https://example.com', 121 esc_url( 122 'example.com', 123 array( 124 'https', 125 'http', 126 ) 127 ) 128 ); 129 $this->assertSame( 130 'http://example.com', 131 esc_url( 132 'example.com', 133 array( 134 'http', 103 135 'https', 104 136 )
Note: See TracChangeset
for help on using the changeset viewer.