Sorcerer's Tower

Welcome to the Tower, my programming and web development blog. Here you will find articles relating to CFML, CSS, HTML, Java, JavaScript and Regular Expressions, plus discussions on the associated tools, technologies, techniques and ideas.

For more general topics, please visit Sorcerer's Isle, where you will find articles on my other interests.

Topics Covered

expandPath bug in CF8

I've just encountered a very annoying bug with the expandPath function in CF8.

Take the following code:

<cfset MyDir = "."/> <cfloop index="i" from="1" to="5"> <cfset MyDir = expandPath(MyDir)/> <cfoutput><br/>#MyDir#</cfoutput> </cfloop>

Run the code through Railo and you will get exactly the right behaviour, with the current directory output five times:

C:\dev\scratch C:\dev\scratch C:\dev\scratch C:\dev\scratch C:\dev\scratch

Now go run the same code with CF8 - and this is what you get:

F:\ColdFusion8\wwwroot\scratch F:\ColdFusion8\wwwroot\scratch\F:\ColdFusion8\wwwroot\scratch F:\ColdFusion8\wwwroot\scratch\F:\ColdFusion8\wwwroot\scratch\F:\ColdFusion8\wwwroot\scratch F:\ColdFusion8\wwwroot\scratch\F:\ColdFusion8\wwwroot\scratch\F:\ColdFusion8\wwwroot\scratch\F:\ColdFusion8\wwwroot\scratch F:\ColdFusion8\wwwroot\scratch\F:\ColdFusion8\wwwroot\scratch\F:\ColdFusion8\wwwroot\scratch\F:\ColdFusion8\wwwroot\scratch\F:\ColdFusion8\wwwroot\scratch

It simply stacks the current directory onto the front each time. Very frustrating.


In order to get round this, I created a regular expression to pull off the last value of any directory containing more than one colon - this will work for Windows machines, but may need to be changed for Linux or MacOSX machines (if the bug affects these).

<cfif isDefined('Server.ColdFusion.ProductName') AND Server.ColdFusion.ProductName EQ 'ColdFusion Server' AND ListLen( MyDir ,':') GT 2> <cfset MyDir = REreplace( MyDir , "^.*([A-Z]:[^:]+)$" , "\1" )/> </cfif>
Posted:
16 August 2008, 17:23
Tags:
ColdFusion
CFML
Comments:
3

CFML Engine Comparison

I have just published the CFML Engine Wiki, a website to compare and detail the features and differences of the top CFML engines.

There is still a lot of work to be done with it, but with it being a wiki I decided it better to release the URL and allow others to help with doing that.

www.cfml-engines.info
Posted:
02 June 2008, 09:07
Tags:
BlueDragon
ColdFusion
CFML
Railo
Web Development
Comments:
2
RSS Atom