Ticket #44533: 44533.2.patch
File 44533.2.patch, 1.8 KB (added by , 6 years ago) |
---|
-
src/wp-includes/functions.php
diff --git c/src/wp-includes/functions.php w/src/wp-includes/functions.php index 8ae58299d6..0dec6df4f5 100644
c w function _device_can_upload() { 5553 5553 * @return bool True if the path is a stream URL. 5554 5554 */ 5555 5555 function wp_is_stream( $path ) { 5556 $wrappers = stream_get_wrappers(); 5557 $wrappers = array_map( 'preg_quote', $wrappers ); 5556 $wrappers = stream_get_wrappers(); 5557 foreach ( $wrappers as &$wrapper ) { 5558 $wrapper = preg_quote( $wrapper, '!' ); 5559 } 5560 5558 5561 $wrappers_re = '(' . join( '|', $wrappers ) . ')'; 5559 5562 5560 5563 return preg_match( "!^$wrappers_re://!", $path ) === 1; -
tests/phpunit/tests/functions.php
diff --git c/tests/phpunit/tests/functions.php w/tests/phpunit/tests/functions.php index d9e3d5fbb8..82d689984b 100644
c w class Tests_Functions extends WP_UnitTestCase { 1451 1451 1452 1452 ); 1453 1453 } 1454 1455 /** 1456 * Test wp_is_stream validation. 1457 * 1458 * @ticket 44533 1459 * @dataProvider data_test_wp_is_stream 1460 * 1461 * @param $path 1462 * @param $expected 1463 */ 1464 public function test_wp_is_stream( $path, $expected ) { 1465 $this->assertSame( $expected, wp_is_stream( $path ) ); 1466 } 1467 1468 /** 1469 * Data provider for stream validation. 1470 * 1471 * @return array 1472 */ 1473 public function data_test_wp_is_stream() { 1474 return array( 1475 // Legitimate stream examples. 1476 array( 'https://example.com', true ), 1477 array( 'ftp://example.com', true ), 1478 array( 'file:///path/to/some/file', true ), 1479 array( 'php://some/php/file.php', true ), 1480 1481 // Non-stream examples. 1482 array( 'fakestream://foo/bar/baz', false ), 1483 array( '../../some/relative/path', false ), 1484 array( 'some/other/relative/path', false ), 1485 array( '/leading/relative/path', false ), 1486 ); 1487 } 1454 1488 }