Ok, after several hours of poking, here are the answers 
expandPath( "../../../../types/" )
returns an unexpected result when calling a remote method from a CFC which is defined in the super class. In this case, youāre invoking the runRemote()
method, which comes from the test-harness\testbox\system\BaseSpec.cfc
class. Furthermore, expandPath()
expands paths relative to the BASE template on the request. The base template is currently seen by BoxLang as BaseSpect.cfc
, so therefore, backing up 4 directories from the test-harness\testbox\system\
folder, puts you in the directory ABOVE your project on disk.
So BoxLang is ācorrectā in itās own way, we just interpret what the base template path is differently than Lucee does when the method youāre calling is in a super class.
I should be able to tweak how remote CFC methods are executed to make the CFC in the URL be the base template instead.
expandPath( "/../../../../types/" )
returns an unexpected result, in part, because BoxLang has a feature that Lucee doesnāt have. Adobe CF has this feature, but they do it a little differently with their custom little IIS connector. Basically, virtual directories (or web server aliases) are made āvisibleā to BoxLang so if you have a virtual directory of /foo
defined in your web server, then you can call expandPath( '/foo' )
and BoxLang will āknowā about that alias and use it to expand the directory without having any CF mappings called /foo
.
The way we accomplish this, is by deferring to the servlet container for any expanded paths that didnāt get expanded by another CF-level mapping.
String expandedPath = servletContext.getRealPath( yourRelativePath );
This allows the servlet container to have the final say in expanding paths which start with a /
character. However, unlike expandpath, the servletās getRealPath()
method will NOT obey ../
thus not allowing you to back up outside of the WARās web root (largely for security). As such, the web root becomes a āceilingā you canāt back up past, and you end up with a final path inside your web root
C:\Users\brad\Documents\GitHub\schema-org\test-harness\types\
Note, this only applies to CommandBox or other WAR servers. This behavior isnāt present in the BoxLang MiniServer because thereās no servlet there.
Thereās not a great workaround for this one as I canāt control how the servlet interprets relative paths. Iāll probably just put in some sort of caveat to skip that behavior if the relative path starts with /..
or something since the result will certainly not be what you expect. It really only makes sense to involve the servlet when the relative path starts with /someAliasName/
.