64 if ( isset(
$vars[
'SERVER_SOFTWARE'] )
65 && isset(
$vars[
'REQUEST_URI'] )
66 && self::haveUndecodedRequestUri(
$vars[
'SERVER_SOFTWARE'] ) )
68 $urlPart =
$vars[
'REQUEST_URI'];
69 } elseif ( isset(
$vars[
'QUERY_STRING'] ) ) {
70 $urlPart =
$vars[
'QUERY_STRING'];
75 if ( self::isUrlExtensionBad( $urlPart, $extWhitelist ) ) {
81 if ( isset(
$vars[
'PATH_INFO'] )
82 && self::isUrlExtensionBad(
$vars[
'PATH_INFO'], $extWhitelist ) )
101 if ( strval( $urlPart ) ===
'' ) {
106 if ( strval( $extension ) ===
'' ) {
111 if ( in_array( $extension,
array(
'php',
'php5' ) ) ) {
115 if ( in_array( $extension, $extWhitelist ) ) {
120 if ( !preg_match(
'/^[a-zA-Z0-9_-]+$/', $extension ) ) {
142 $questionPos = strpos( $url,
'?' );
143 if ( $questionPos ===
false ) {
144 $beforeQuery = $url .
'?';
146 } elseif ( $questionPos === strlen( $url ) - 1 ) {
150 $beforeQuery = substr( $url, 0, $questionPos + 1 );
151 $query = substr( $url, $questionPos + 1 );
161 $url = $beforeQuery .
$query;
162 if ( self::isUrlExtensionBad( $url, $extWhitelist ) ) {
195 $hashPos = strpos( $url,
'#' );
196 if ( $hashPos !==
false ) {
197 $urlLength = $hashPos;
199 $urlLength = strlen( $url );
201 $remainingLength = $urlLength;
202 while ( $remainingLength > 0 ) {
204 $pos += strcspn( $url,
'.', $pos, $remainingLength );
205 if ( $pos >= $urlLength ) {
212 $remainingLength = $urlLength - $pos;
216 $nextPos = $pos + strcspn( $url,
"<>\\\"/:|?*.", $pos, $remainingLength );
217 if ( $nextPos >= $urlLength ) {
220 return substr( $url, $pos, $urlLength - $pos );
222 if ( $url[$nextPos] ===
'?' ) {
225 $extension = substr( $url, $pos, $nextPos - $pos );
226 if ( strcasecmp( $extension,
'exe' ) && strcasecmp( $extension,
'dll' ) &&
227 strcasecmp( $extension,
'cgi' ) )
236 $remainingLength = $urlLength - $pos;
260 static $whitelist =
array(
264 if ( preg_match(
'/^(.*?)($|\/| )/', $serverSoftware, $m ) ) {
265 return in_array( $m[1], $whitelist );