Permalink
Browse files

Improved the "bad model" filter for Sandbox

Cleans up bad model paths instead of blocking them
  • Loading branch information...
1 parent f43d302 commit 9abd01e5ca27efe5abe33384a7b13d9e326b7540 @robotboy655 robotboy655 committed Jun 1, 2016
Showing with 8 additions and 1 deletion.
  1. +8 −1 garrysmod/gamemodes/sandbox/gamemode/commands.lua
@@ -8,7 +8,14 @@ include( "prop_tools.lua" )
function CCSpawn( player, command, arguments )
if ( arguments[ 1 ] == nil ) then return end
- if ( arguments[ 1 ]:find( "[./\\][/\\]" ) ) then return end
+ if ( arguments[ 1 ]:find( "%.[/\\]" ) ) then return end
+
+ -- Clean up the path from attempted blacklist bypasses
+ arguments[ 1 ] = arguments[ 1 ]:gsub( "\\\\+", "/" )
+ arguments[ 1 ] = arguments[ 1 ]:gsub( "//+", "/" )
+ arguments[ 1 ] = arguments[ 1 ]:gsub( "\\/+", "/" )
+ arguments[ 1 ] = arguments[ 1 ]:gsub( "/\\+", "/" )
+
if ( !gamemode.Call( "PlayerSpawnObject", player, arguments[ 1 ], arguments[ 2 ] ) ) then return end
if ( !util.IsValidModel( arguments[ 1 ] ) ) then return end

0 comments on commit 9abd01e

Please sign in to comment.