@@ -486,3 +486,41 @@ enum MyEnum {
486486 echo $ _POST ['foo ' ]; // OK.
487487 }
488488}
489+
490+ // Good, has a nonce check. Ensure the check is case-insensitive as function names are case-insensitive in PHP.
491+ function ajax_process () {
492+ CHECK_AJAX_REFERER ( 'something ' );
493+
494+ update_post_meta ( (int ) $ _POST ['id ' ], 'a_key ' , $ _POST ['a_value ' ] );
495+ }
496+
497+ // phpcs:set WordPress.Security.NonceVerification customNonceVerificationFunctions[] MIXED_case_NAME
498+ function non_ascii_characters () {
499+ MIXED_case_NAME ( $ _POST ['something ' ] ); // Passing $_POST to ensure the sniff bails correctly for variables inside the nonce verification function.
500+
501+ update_post_meta ( (int ) $ _POST ['id ' ], 'a_key ' , $ _POST ['a_value ' ] );
502+ }
503+ // 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[]
0 commit comments