|
2 | 2 |
|
3 | 3 | use PHPUnit\Framework\TestCase; |
4 | 4 | use WordPress\DataLiberation\URL\CSSUrlProcessor; |
5 | | -use WordPress\DataLiberation\URL\WPURL; |
6 | 5 |
|
7 | 6 | class CSSUrlProcessorTest extends TestCase { |
8 | 7 |
|
@@ -144,6 +143,10 @@ public static function provider_test_css_escape_decoding() { |
144 | 143 | 'background: url(https://example.com/\\4E2D\\6587.png)', |
145 | 144 | 'https://example.com/中文.png', |
146 | 145 | ), |
| 146 | + 'Multiple trailing whitespaces after the hex escape are preserved' => array( |
| 147 | + 'background: url("https://example.com/test\\26 more.png")', |
| 148 | + 'https://example.com/test& more.png', |
| 149 | + ), |
147 | 150 |
|
148 | 151 | // Case insensitivity of hex digits |
149 | 152 | 'Lowercase hex digits' => array( |
@@ -323,4 +326,16 @@ public function test_handles_data_uris() { |
323 | 326 | $this->assertTrue( $processor->next_url() ); |
324 | 327 | $this->assertEquals( 'data:image/png;base64,iVBORw0KGgo=', $processor->get_raw_url() ); |
325 | 328 | } |
| 329 | + |
| 330 | + public function test_handles_1mb_data_uri() { |
| 331 | + // Test with 1MB data URI using state machine parser |
| 332 | + // The parser can handle arbitrarily large URLs without PCRE limits |
| 333 | + $data_uri = 'data:image/png;base64,' . str_repeat( 'A', 2 * 1024 * 1024 ); |
| 334 | + $css_value = 'background: url("' . $data_uri . '")'; |
| 335 | + $processor = new CSSUrlProcessor( $css_value ); |
| 336 | + |
| 337 | + $this->assertTrue( $processor->next_url(), 'Failed to find URL in CSS' ); |
| 338 | + $this->assertEquals( $data_uri, $processor->get_raw_url() ); |
| 339 | + } |
| 340 | + |
326 | 341 | } |
0 commit comments