Error graph.cfm

Hi,

For one of our clients we use the cfimage tag to generate captcha’s:

<cfimage action="captcha" fontSize="24" fonts="Times New Roman" width="200" height="50" text="#rndString#">

We notice a lot of error messages in the exception.log:

“ERROR”,“ajp-nio-0:0:0:0:0:0:0:1-8009-exec-1238”,“01/13/2022”,“11:50:05”,"","file or directory [C:/inetpub/wwwroot/XXX/WEB-INF/lucee/temp//graph/94AD4391-7F5B-4DA3-A687BFE7FFBD63D3.png] does not exist;file or directory [C:/inetpub/wwwroot/XXX/WEB-INF/lucee/temp//graph/94AD4391-7F5B-4DA3-A687BFE7FFBD63D3.png] does not exist;lucee.runtime.exp.ExpressionException: file or directory [C:/inetpub/wwwroot/XXX/WEB-INF/lucee/temp//graph/94AD4391-7F5B-4DA3-A687BFE7FFBD63D3.png] does not exist

Notice the double slash between temp and graph: temp//graph

Graph.cfm has this line of code:

<cfcontent file="#GetTempDirectory()#/graph/#listLast(url.img,'/\#server.separator.file#')#" type="image/#url.type#"><cfsetting showdebugoutput="no">

Since GetTempDirectory() already produces a trailing slash, /graph/ should be replaced by graph/

But I don’t understand why this message isn’t generated all the time. I haven’t been able to reproduce the error myself.

Any thoughts on this matter?

OS: Windows Server 2019 (10.0) 64bit
Java Version: 11.0.7 (AdoptOpenJDK) 64bit
Tomcat Version: Apache Tomcat/9.0.35
Lucee Version: Lucee 5.3.8.206

Not saying this IS the issue, but I doubt this is an issue on linux.

Is longpaths enabled?
Is 8dot3 naming disabled?

Enable longpaths and disable the 8dot3 naming, not saying that is the reason for the double “//” as that is a path error, but the same sent is at near 100 characters, if you path is over 125 characters, any file move, change or copy is doubled, which can cause all kinds of fun file naming breaks.

My comment on linux is that, its more strict in the sense that file paths are not fuzzy based.

windows tries its best to file a file in \c:\ as well as .c:\

The documentation for file paths in windows os :

now to really bake your noodle, java loves \ in file paths
https://docs.oracle.com/javase/tutorial/essential/io/pathOps.html

1 Like

Hi @Roeland

I’ve just tested this and on my Linux and Windows dev environments. While double slashes are being created, I didn’t see them causing any issues while being requested. Looks like the OS knows how to deal with those paths.

However, I’ve created a PR as a contrib right away:

I’ve seen similar issues when creating bigger images on-the-fly with image-magick and placing the request link in the html code almost simutaniously, so that the image hasn’t already been fully written to the file system. But I’m not sure if this situation also applies here.

The issue could also be some kind of pages/URLs saved locally in the client browser (e.g. set as bookmarks/favorites) trying to retrieve some files that have already been removed from the temp-folder.

1 Like

Hi Andreas,

Thanks for your time and effort.

I changed graph.cfm to get rid of the extra slash, but you’re right: the problem persists. I will look further into it.

the file resource handling layer in Lucee normalises paths, so that a path with / \ or work on unix and windows, which I don’t think this is the problem.