Changeset 42011 for trunk/src/wp-includes/functions.php
- Timestamp:
- 10/24/2017 11:14:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/functions.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r42007 r42011 4253 4253 * @return int 0 means nothing is wrong, greater than 0 means something was wrong. 4254 4254 */ 4255 function validate_file( $file, $allowed_files = '' ) { 4256 if ( false !== strpos( $file, '..' ) ) 4255 function validate_file( $file, $allowed_files = array() ) { 4256 // `../` on its own is not allowed: 4257 if ( '../' === $file ) { 4257 4258 return 1; 4258 4259 if ( false !== strpos( $file, './' ) ) 4259 } 4260 4261 // More than one occurence of `../` is not allowed: 4262 if ( preg_match_all( '#\.\./#', $file, $matches, PREG_SET_ORDER ) && ( count( $matches ) > 1 ) ) { 4260 4263 return 1; 4261 4264 } 4265 4266 // `../` which does not occur at the end of the path is not allowed: 4267 if ( false !== strpos( $file, '../' ) && '../' !== mb_substr( $file, -3, 3 ) ) { 4268 return 1; 4269 } 4270 4271 // Files not in the allowed file list are not allowed: 4262 4272 if ( ! empty( $allowed_files ) && ! in_array( $file, $allowed_files ) ) 4263 4273 return 3; 4264 4274 4275 // Absolute Windows drive paths are not allowed: 4265 4276 if (':' == substr( $file, 1, 1 ) ) 4266 4277 return 2;
Note: See TracChangeset
for help on using the changeset viewer.