| Server IP : 121.121.20.254 / Your IP : 216.73.216.202 Web Server : Microsoft-IIS/10.0 System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64 User : IUSR ( 0) PHP Version : 8.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/6pocketz/wp-content/plugins/angie/modules/super-admin/classes/ |
Upload File : |
<?php
namespace Angie\Modules\SuperAdmin\Classes;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Resolves user-supplied paths safely under ABSPATH using native WP functions.
*
* validate_file() rejects traversal patterns (../, :) so no custom dotdot
* resolver is needed. wp_normalize_path() handles slash normalization.
*/
class Path_Validator {
public static function resolve_under_abspath( string $path ): string {
$path = trim( $path );
if ( empty( $path ) ) {
return '';
}
if ( false !== strpos( $path, "\0" ) ) {
return '';
}
if ( 0 !== validate_file( $path ) && 0 !== validate_file( $path, [ ABSPATH ] ) ) {
return '';
}
$absolute = path_is_absolute( $path ) ? $path : path_join( ABSPATH, $path );
$normalized = wp_normalize_path( $absolute );
if ( empty( $normalized ) ) {
return '';
}
$abspath_normalized = rtrim( wp_normalize_path( ABSPATH ), '/' );
if ( 0 !== strpos( $normalized, $abspath_normalized . '/' ) && $normalized !== $abspath_normalized ) {
return '';
}
return $normalized;
}
}