Last active
December 16, 2015 23:59
-
-
Save adamcameron/5517298 to your computer and use it in GitHub Desktop.
A series of functions, each implementing a test of whether a path is within the current webroot.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
component { | |
public boolean function matt(path) { | |
var boolReturn = false; | |
var local = {}; | |
local.isInRoot = (listLen( arguments.path, "\/") - listLen(ExpandPath('/'), "\/")); | |
if (local.isInRoot GTE 0) { | |
boolReturn = true; | |
} | |
return boolReturn; | |
} | |
boolean function dale(String path) { | |
local.root = expandPath("/"); | |
local.root = left(local.root, len(local.root) -1); | |
arguments.path = replace(arguments.path, "/", "\", "ALL"); | |
local.result = arguments.path contains local.root ? true : false; | |
return local.result; | |
} | |
boolean function winston(required string fileSystemPath) | |
{ | |
if(!Len(Arguments.fileSystemPath)) | |
{ | |
return false; | |
} | |
Local.web_root = ListToArray(ExpandPath('/'), '/\'); | |
Local.path = ListToArray(Arguments.fileSystemPath, '/\'); | |
return Local.web_root.equals(Local.path.subList(0, ArrayLen(Local.web_root))); | |
} | |
public boolean function adam(required string fileSystemPath){ | |
var dirCurrent = createObject("java", "java.io.File").init(fileSystemPath).getCanonicalPath(); | |
var dirBase = createObject("java", "java.io.File").init(expandPath("/")).getCanonicalPath(); | |
return find(dirBase, dirCurrent); | |
} | |
public boolean function bruce(required string fileSystemPath){ | |
arguments.filesystempath=replace(arguments.filesystempath,"\","/","all"); | |
if(compare(left(expandpath("/"), len(arguments.filesystempath)), arguments.filesystempath) EQ 0){ | |
return true; | |
}else{ | |
return false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment