Skip to content

Commit 2a0f154

Browse files
authored
Merge pull request #1673 from WordPress-Coding-Standards/feature/1659-validatedsanitizedinput-allow-for-various-additional-safe-functions
Sniff::$unslashingSanitizingFunctions: add doubleval() and count()
2 parents f4e645f + c088b1b commit 2a0f154

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

WordPress/Sniff.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,13 @@ abstract class Sniff implements PHPCS_Sniff {
309309
protected $unslashingSanitizingFunctions = array(
310310
'absint' => true,
311311
'boolval' => true,
312+
'count' => true,
313+
'doubleval' => true,
312314
'floatval' => true,
313315
'intval' => true,
314316
'is_array' => true,
315317
'sanitize_key' => true,
318+
'sizeof' => true,
316319
);
317320

318321
/**

WordPress/Tests/Security/ValidatedSanitizedInputUnitTest.inc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,12 @@ if ( isset( $_GET['unslash_check'] ) ) {
216216
$clean = sanitize_text_field( WP_Faker::wp_unslash( $_GET['unslash_check'] ) ); // Bad x1 - unslash.
217217
$clean = WP_Faker\sanitize_text_field( wp_unslash( $_GET['unslash_check'] ) ); // Bad x1 - sanitize.
218218
}
219+
220+
function test_more_safe_functions() {
221+
if ( ! isset( $_GET['test'] ) ) {
222+
return;
223+
}
224+
225+
$float = doubleval( $_GET['test'] ); // OK.
226+
$count = count( $_GET['test'] ); // Issue #1659; OK.
227+
}

0 commit comments

Comments
 (0)