@@ -35,7 +35,7 @@ public static function provider_test_css_escape_decoding() {
3535 "background: url(https://example.com/hello \u{5c}000020 world.png) " ,
3636 'https://example.com/hello world.png ' ,
3737 ),
38- "8-digit space is treated as a replacement character followed by a string ` \u{5c}20`: ` \u{5c}00000020` " => array (
38+ "8-digit space is treated as a replacement character followed by a string ` \u{5c}20`: ` \u{5c}00000020` " => array (
3939 "background: url(https://example.com/hello \u{5c}00000020world.png) " ,
4040 "https://example.com/hello \u{FFFD}20world.png " ,
4141 ),
@@ -160,49 +160,49 @@ public static function provider_test_css_escape_decoding() {
160160 "background: url(https://example.com/ \u{5c}00002F \u{5c}000041.png) " ,
161161 'https://example.com//A.png ' ,
162162 ),
163- 'Mixed case hex digits (2f 2F) with trailing whitespace ' => array (
163+ 'Mixed case hex digits (2f 2F) with trailing whitespace ' => array (
164164 // Note: The whitespace after hex escapes is consumed as part of the escape sequence
165165 "background: url( \u{22}https://example.com \u{5c}2F \u{5c}2f file.png \u{22}) " ,
166166 'https://example.com//file.png ' ,
167167 ),
168168
169169 // Very low codepoint
170170 'Control character `\u{5c}1` (SOH) ' => array (
171- // https://example.com/test\1 .png
171+ // https://example.com/test\1 .png
172172 "background: url( \u{22}https://example.com/test \u{5c}1 .png \u{22}) " ,
173173 "https://example.com/test \u{01}.png " ,
174174 ),
175175
176176 // Special URL characters escaped
177177 'Escaped forward slash ' => array (
178- // https://example.com/path\/to\/file.png
178+ // https://example.com/path\/to\/file.png
179179 "background: url(https://example.com/path \u{5c}\u{2f}to \u{5c}\u{2f}file.png) " ,
180180 'https://example.com/path/to/file.png ' ,
181181 ),
182182 'Escaped question mark ' => array (
183- // https://example.com/file.png\?query
183+ // https://example.com/file.png\?query
184184 "background: url(https://example.com/file.png \u{5c}\u{003f}query) " ,
185185 'https://example.com/file.png?query ' ,
186186 ),
187187 'Escaped hash ' => array (
188- // https://example.com/file.png\#anchor
188+ // https://example.com/file.png\#anchor
189189 "background: url(https://example.com/file.png \u{5c}\u{0023}anchor) " ,
190190 'https://example.com/file.png#anchor ' ,
191191 ),
192192
193193 // Consecutive backslashes
194194 'Two backslashes ' => array (
195- // https://example.com/test\\.png
195+ // https://example.com/test\\.png
196196 "background: url(https://example.com/test \u{5c}\u{5c}.png) " ,
197197 "https://example.com/test \u{5c}.png " ,
198198 ),
199199 'Three backslashes ' => array (
200- // https://example.com/test\\\.png
200+ // https://example.com/test\\\.png
201201 "background: url(https://example.com/test \u{5c}\u{5c}\u{5c}.png) " ,
202202 "https://example.com/test \u{5c}.png " ,
203203 ),
204204 'Four backslashes ' => array (
205- // https://example.com/test\\\\.png
205+ // https://example.com/test\\\\.png
206206 "background: url(https://example.com/test \u{5c}\u{5c}\u{5c}\u{5c}.png) " ,
207207 "https://example.com/test \u{5c}\u{5c}.png " ,
208208 ),
@@ -240,30 +240,30 @@ public static function provider_test_basic_css_url_detection() {
240240 'should-detect ' => true ,
241241 'url ' => 'https://example.com/image.png ' ,
242242 ),
243- 'Quoted URL with a whitespace before the opening quote ' => array (
243+ 'Quoted URL with a whitespace before the opening quote ' => array (
244244 'css ' => 'background: url( "https://example.com/image.png") ' ,
245245 'should-detect ' => true ,
246246 'url ' => 'https://example.com/image.png ' ,
247247 ),
248- 'Unquoted URL with whitespace inside the parentheses ' => array (
248+ 'Unquoted URL with whitespace inside the parentheses ' => array (
249249 'css ' => 'background: url( https://example.com/image.png ) ' ,
250250 'should-detect ' => true ,
251251 'url ' => 'https://example.com/image.png ' ,
252252 ),
253- 'Unquoted URL with whitespace in the middle of the URL ' => array (
253+ 'Unquoted URL with whitespace in the middle of the URL ' => array (
254254 'css ' => 'background: url( https://example.com/ image.png ) ' ,
255- 'should-detect ' => false
255+ 'should-detect ' => false ,
256256 ),
257- 'Quoted URL with whitespace in the middle of the URL ' => array (
257+ 'Quoted URL with whitespace in the middle of the URL ' => array (
258258 'css ' => 'background: url( "https://example.com/ image.png" ) ' ,
259259 'should-detect ' => true ,
260260 'url ' => 'https://example.com/ image.png ' ,
261261 ),
262- 'Quoted URL with a comment before the opening quote ' => array (
262+ 'Quoted URL with a comment before the opening quote ' => array (
263263 'css ' => 'background: url(/**/"https://example.com/image.png") ' ,
264264 'should-detect ' => false ,
265265 ),
266- 'Quoted URL with a whitespace after the closing quote ' => array (
266+ 'Quoted URL with a whitespace after the closing quote ' => array (
267267 'css ' => 'background: url("https://example.com/image.png" ) ' ,
268268 'should-detect ' => true ,
269269 'url ' => 'https://example.com/image.png ' ,
@@ -288,7 +288,7 @@ public static function provider_test_basic_css_url_detection() {
288288 ),
289289
290290 // Verify real URLs are found after skipped content
291- 'Background URL placed after a CSS comment containing a URL ' => array (
291+ 'Background URL placed after a CSS comment containing a URL ' => array (
292292 'css ' => '/* background: url("https://commented.com/image.png"); */ background: url("https://real.com/image.png") ' ,
293293 'should-detect ' => true ,
294294 'url ' => 'https://real.com/image.png ' ,
@@ -352,91 +352,91 @@ public static function provider_test_url_replacement() {
352352 'expected ' => 'background: url("https://new.com/image.png") ' ,
353353 ),
354354
355- 'URL with double quotes in path ' => array (
355+ 'Sets new URL with double quotes in path ' => array (
356356 'input ' => 'background: url("https://old.com/old.png") ' ,
357357 'new_url ' => 'https://example.com/path"with"quotes.png ' ,
358358 'expected ' => "background: url( \u{22}https://example.com/path \u{5c}22 with \u{5c}22 quotes.png \u{22}) " , // \22 = "
359359 ),
360- 'URL with single quotes in single-quoted string ' => array (
360+ 'Sets new URL with single quotes in single-quoted string ' => array (
361361 'input ' => "background: url('https://old.com/old.png') " ,
362362 'new_url ' => "https://example.com/path'with'quotes.png " ,
363363 'expected ' => "background: url('https://example.com/path'with'quotes.png') " , // Single quotes not escaped in single-quoted context
364364 ),
365- 'URL with backslashes in path ' => array (
365+ 'Sets new URL with backslashes in path ' => array (
366366 'input ' => 'background: url("https://old.com/old.png") ' ,
367367 'new_url ' => 'https://example.com/path \\with \\backslashes.png ' ,
368368 'expected ' => "background: url( \u{22}https://example.com/path \u{5c}5C with \u{5c}5C backslashes.png \u{22}) " , // \5C = \
369369 ),
370- 'URL with parentheses in path ' => array (
370+ 'Sets new URL with parentheses in path ' => array (
371371 'input ' => 'background: url("https://old.com/old.png") ' ,
372372 'new_url ' => 'https://example.com/file(1).png ' ,
373373 'expected ' => 'background: url("https://example.com/file(1).png") ' ,
374374 ),
375- 'URL with spaces in path ' => array (
375+ 'Sets new URL with spaces in path ' => array (
376376 'input ' => 'background: url("https://old.com/old.png") ' ,
377377 'new_url ' => 'https://example.com/path with spaces.png ' ,
378378 'expected ' => 'background: url("https://example.com/path with spaces.png") ' ,
379379 ),
380- 'URL with newline character ' => array (
380+ 'Sets new URL with newline character ' => array (
381381 'input ' => 'background: url("https://old.com/old.png") ' ,
382382 'new_url ' => "https://example.com/path \nwith \nnewlines.png " ,
383383 'expected ' => "background: url( \u{22}https://example.com/path \u{5c}a with \u{5c}a newlines.png \u{22}) " , // \a = newline
384384 ),
385- 'URL with tab character ' => array (
385+ 'Sets new URL with tab character ' => array (
386386 'input ' => 'background: url("https://old.com/old.png") ' ,
387387 'new_url ' => "https://example.com/path \twith \ttabs.png " ,
388388 'expected ' => "background: url( \u{22}https://example.com/path \twith \ttabs.png \u{22}) " , // Tab preserved as-is
389389 ),
390390
391- 'Replace with data URI ' => array (
391+ 'Sets new URL with data URI ' => array (
392392 'input ' => 'background: url("https://old.com/image.png") ' ,
393393 'new_url ' => 'data:image/png;base64,iVBORw0KGgo= ' ,
394394 'expected ' => 'background: url("data:image/png;base64,iVBORw0KGgo=") ' ,
395395 ),
396- 'Replace data URI with regular URL ' => array (
396+ 'Sets new URL with data URI with regular URL ' => array (
397397 'input ' => 'background: url("data:image/png;base64,iVBORw0KGgo=") ' ,
398398 'new_url ' => 'https://new.com/image.png ' ,
399399 'expected ' => 'background: url("https://new.com/image.png") ' ,
400400 ),
401401
402- 'Replace with relative URL ' => array (
402+ 'Sets new URL with relative URL ' => array (
403403 'input ' => 'background: url("https://old.com/image.png") ' ,
404404 'new_url ' => '/images/new.png ' ,
405405 'expected ' => 'background: url("/images/new.png") ' ,
406406 ),
407- 'Replace with path-only URL ' => array (
407+ 'Sets new URL with path-only URL ' => array (
408408 'input ' => 'background: url("https://old.com/image.png") ' ,
409409 'new_url ' => '../images/new.png ' ,
410410 'expected ' => 'background: url("../images/new.png") ' ,
411411 ),
412412
413- 'URL with emoji ' => array (
413+ 'Sets new URL with emoji ' => array (
414414 'input ' => 'background: url("https://old.com/old.png") ' ,
415415 'new_url ' => 'https://example.com/😀.png ' ,
416416 'expected ' => 'background: url("https://example.com/😀.png") ' ,
417417 ),
418- 'URL with Chinese characters ' => array (
418+ 'Sets new URL with Chinese characters ' => array (
419419 'input ' => 'background: url("https://old.com/old.png") ' ,
420420 'new_url ' => 'https://example.com/中文.png ' ,
421421 'expected ' => 'background: url("https://example.com/中文.png") ' ,
422422 ),
423423
424- 'Empty URL ' => array (
424+ 'Sets new URL that is an empty string ' => array (
425425 'input ' => 'background: url("https://old.com/image.png") ' ,
426426 'new_url ' => '' ,
427427 'expected ' => 'background: url("") ' ,
428428 ),
429- 'URL with query parameters ' => array (
429+ 'Sets new URL with query parameters ' => array (
430430 'input ' => 'background: url("https://old.com/old.png") ' ,
431431 'new_url ' => 'https://example.com/image.png?v=123&t=456 ' ,
432432 'expected ' => 'background: url("https://example.com/image.png?v=123&t=456") ' ,
433433 ),
434- 'URL with fragment ' => array (
434+ 'Sets new URL with fragment ' => array (
435435 'input ' => 'background: url("https://old.com/old.png") ' ,
436436 'new_url ' => 'https://example.com/image.png#section ' ,
437437 'expected ' => 'background: url("https://example.com/image.png#section") ' ,
438438 ),
439- 'Non- URL content ' => array (
439+ 'Sets new URL that is not actually a valid URL ' => array (
440440 'input ' => 'background: url("https://old.com/old.png") ' ,
441441 'new_url ' => 'WordPress is great! ' ,
442442 'expected ' => 'background: url("WordPress is great!") ' ,
@@ -560,7 +560,7 @@ public function test_comprehensive_url_replacement_in_complex_css() {
560560 $ processor = new CSSURLProcessor ( $ input_css );
561561
562562 // Track which URLs we found for verification
563- $ found_urls = array ();
563+ $ found_urls = array ();
564564 $ url_counter = 1 ;
565565
566566 // Replace all URLs with unique identifiers
@@ -574,7 +574,7 @@ public function test_comprehensive_url_replacement_in_complex_css() {
574574 $ new_url = "https://replaced.test/url- {$ url_counter }" ;
575575 $ processor ->set_raw_url ( $ new_url );
576576
577- $ url_counter ++ ;
577+ ++ $ url_counter ;
578578 }
579579
580580 // Verify the final CSS matches expected output
@@ -746,5 +746,4 @@ public function test_large_data_uri_does_not_allocate_additional_memory() {
746746 // Note: We can't restore if current usage exceeds the original limit
747747 @ini_set ( 'memory_limit ' , $ original_limit );
748748 }
749-
750749}
0 commit comments