Skip to content

Commit 7ee8af7

Browse files
committed
Add tests safeguarding that non-ANSCII characters are handled correctly when looking for nonce verification functions
1 parent f9c4005 commit 7ee8af7

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

WordPress/Tests/Security/NonceVerificationUnitTest.1.inc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,3 +501,26 @@ function non_ascii_characters() {
501501
update_post_meta( (int) $_POST['id'], 'a_key', $_POST['a_value'] );
502502
}
503503
// phpcs:set WordPress.Security.NonceVerification customNonceVerificationFunctions[]
504+
505+
/*
506+
* Test case handling of non-ASCII characters in function names.
507+
*/
508+
// phpcs:set WordPress.Security.NonceVerification customNonceVerificationFunctions[] déjà_vu
509+
function same_function_same_case() {
510+
déjà_vu( 'something' ); // Ok.
511+
512+
update_post_meta( (int) $_POST['id'], 'a_key', $_POST['a_value'] );
513+
}
514+
515+
function same_function_different_case() {
516+
DéJà_VU( 'something' ); // Ok.
517+
518+
update_post_meta( (int) $_POST['id'], 'a_key', $_POST['a_value'] );
519+
}
520+
521+
function different_function_name() {
522+
dÉjÀ_vu( 'something' ); // Bad, dÉjÀ_vu() and déjà_vu() are NOT the same function.
523+
524+
update_post_meta( (int) $_POST['id'], 'a_key', $_POST['a_value'] );
525+
}
526+
// phpcs:set WordPress.Security.NonceVerification customNonceVerificationFunctions[]

WordPress/Tests/Security/NonceVerificationUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public function getErrorList( $testFile = '' ) {
7474
453 => 1,
7575
470 => 1,
7676
478 => 1,
77+
524 => 2,
7778
);
7879

7980
case 'NonceVerificationUnitTest.2.inc':

0 commit comments

Comments
 (0)