mirrored from git://develop.git.wordpress.org/
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Meta: Sanitize meta key before checking protection status.
Props zieladam, peterwilsoncc, xknown, whyisjake. Merges [49377,49381] to trunk. git-svn-id: https://develop.svn.wordpress.org/trunk@49387 602fd350-edb4-49c9-b593-d223f7449a82
- Loading branch information
Showing
2 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
/** | ||
* @group meta | ||
* @covers ::is_protected_meta | ||
*/ | ||
class Tests_Meta_isProtectedMeta extends WP_UnitTestCase { | ||
|
||
/** | ||
* @dataProvider protected_data | ||
*/ | ||
public function test_protected( $key ) { | ||
$this->assertTrue( is_protected_meta( $key ) ); | ||
} | ||
|
||
public function protected_data() { | ||
$protected_keys = array( | ||
array( '_wp_attachment' ), | ||
); | ||
for ( $i = 0, $max = 31; $i < $max; $i ++ ) { | ||
$protected_keys[] = array( chr( $i ) . '_wp_attachment' ); | ||
} | ||
for ( $i = 127, $max = 159; $i <= $max; $i ++ ) { | ||
$protected_keys[] = array( chr( $i ) . '_wp_attachment' ); | ||
} | ||
$protected_keys[] = array( chr( 95 ) . '_wp_attachment' ); | ||
|
||
return $protected_keys; | ||
} | ||
|
||
/** | ||
* @dataProvider unprotected_data | ||
*/ | ||
public function test_unprotected( $key ) { | ||
$this->assertFalse( is_protected_meta( $key ) ); | ||
} | ||
|
||
public function unprotected_data() { | ||
$unprotected_keys = array( | ||
array( 'singleword' ), | ||
array( 'two_words' ), | ||
array( 'ąŌ_not_so_protected_meta' ), | ||
); | ||
|
||
for ( $i = 32, $max = 94; $i <= $max; $i ++ ) { | ||
$unprotected_keys[] = array( chr( $i ) . '_wp_attachment' ); | ||
} | ||
for ( $i = 96, $max = 126; $i <= $max; $i ++ ) { | ||
$unprotected_keys[] = array( chr( $i ) . '_wp_attachment' ); | ||
} | ||
|
||
return $unprotected_keys; | ||
} | ||
|
||
} |