Skip to content

Commit

Permalink
Sanitise hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
barryo committed Jan 31, 2018
1 parent 69a8136 commit 4084627
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions library/OSS/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,14 @@ public static function genUrl( $controller = false, $action = false, $module = f
case 'HTTP_X_FORWARDED_HOST':
$host = $_SERVER['HTTP_X_FORWARDED_HOST'];
break;

case 'REPLACE':
$host = $options['utils']['genurl']['host_replace'];
// need to make sure the host is an actual host
if( preg_match( "/^(http[s]{0,1}:\/\/[a-zA-Z0-9\-_\.]+)[\/]{0,1}.*/", $options['utils']['genurl']['host_replace'], $host_array ) ) {
$host = $host_array[1];
} else {
$host = $options['utils']['genurl']['host_replace'];
}
break;

default:
Expand Down

0 comments on commit 4084627

Please sign in to comment.