A client came to me today with a wierd problem. There were trying to run a simple custom tag using cfmodule and a mapping, but for some reason, the custom tag could not be found.
So, the first thing I did was verify the folder specified in the mappings in the CF admin. This was set perfectly. For the heck of it, I then tried using the ServiceFactory to get the mapping. When I ran directoryExists() on the value, however, it returned false. At this point, I was going crazy. When all of a sudden I noticed something.
There was a space in front of the folder name. It was next to impossible to see - but once I did, it was completely obvious. I'm guessing the CF Admin should probably call trim() on folders when you create a mapping.
Archived Comments
One thing I've noticed is that the CFAdmin often pads values with spaces either side when displaying. For example, if you go into "custom tag paths" then the actual path is linked so you can edit it. But the link actually includes whitespace either side of the path.
In the past I have fallen into the trap of usind the good old "copy and paste" method of creating a new custom tag path and have accidentally copied the spaces along too. Like you said -- one little trim() call could have saved a lot of hassle!
But it also makes me wonder why MM decided to use the "space padding" rather than just doing the job properly wil CSS...
though it'd probably save headaches, I don't think CFModule should trim things for you, and neither should the admin, when it comes to directory paths. It's probably possible in some OS's to have leading or trailing directory spaces... I wouldn't recommend it, but if it's possible then I wouldn't fault Macromedia for allowing it. It's the resposibility of the administrator, after all, to ensure that all configuration settings are entered accurately... just like it's the responsibility of developers to ensure they pass them correctly.
It's not an easy mis-configuration or parameter typo to catch, I agree. I've had similar things happen in J2EE configuration files.... not very fun to debug at all. Chalk it up as just being part of the joy of software development, I suppose ;)
I wouldn't make cfmodule do an auto trim, it should respect what you pass in, but I disagree about the cf admin. Windows seems to ignore spaces. I don't have a linux box to test on. But there aren't -that- many OSes that CF supports, so it would easy enough to test I'd think. Anyway, we will agree to disagree.
It is possible to create directories or files with leading/trailing spaces in both windows (via the command prompt) and linux. As to why on earth you'd want to do that, I have no idea... :)
Hmm, Tim, when I tried it in XP it stripped it out.
Try going to a command prompt and do:
mkdir " test "
But my apologies: it does still strip out training spaces.