-
-
Save tristanlee85/7e14f12499170d34246c to your computer and use it in GitHub Desktop.
cfml-.equals
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
var local.tempFile = createObject("java", "java.io.File").init(getTempDirectory() & arguments.filenameExample); | |
// throws "Invalid CFML construct" at .equals() | |
if (!local.tempFile.getCanonicalFile().getName().equals(local.tempFile)) {...} | |
// no error when assigned to a variable | |
var local.tempFileName = local.tempFile.getCanonicalFile().getName(); | |
if (!local.tempFileName.equals(arguments.filenameExample)) {...} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@ryanguill,
Good catch on the code. I had the argument for .equals() wrong when I typed this out. I should have just copied and pasted my actual app code. The point of the code is to be able the validate if the filename can be written to the disk as is. Here's the full example:
hfgdfdh$R(*^&^...^.pdf
is a writable file for Unix platforms.hfgdfdh$R(*/^&^...^.pdf
is invalid because the canonical form of the File's name is^&^...^.pdf
(due to the forward slash).And I am not shocked at all that is works on Railo, but not CF10. :)