Ben Nadel
On User Experience (UX) Design, JavaScript, ColdFusion, Node.js, Life, and Love.
Ben Nadel at dev.Objective() 2015 (Bloomington, MN) with: Kev McCabe
Ben Nadel at dev.Objective() 2015 (Bloomington, MN) with: Kev McCabe@bigmadkev )

Calling Canonicalize() On An Empty-String Returns NULL In Lucee 5.2.9.31

By Ben Nadel on
Tags: ColdFusion

For the last couple of weeks, we've been working to migrate some Adobe ColdFusion 10 code over to Lucee 5 code. And, we've been debugging little discrepancies along the way. Yesterday, I ran into another small divergence in the behavior between the two platforms. It seems that calling the canonicalize() function on an empty String will return NULL in Lucee 5.2.9.31. In comparison, Adobe ColdFusion always returns a String, even when canonicalize() is called on an empty String.

To see this in action, all we have to is run canonicalize() on an empty string and then try to reference the result without any safe-guards:

  • <cfscript>
  •  
  • value = canonicalize( "", true, true );
  •  
  • writeDump( "VALUE: [#value#]" );
  •  
  • </cfscript>

Obviously, this is a trite example as there would be no need to run canonicalize() on an explicitly empty String. However, imagine that the value being passed into the canonicalize() function was a dynamic, user-provided piece of content. It might hold a lot of data; it might hold no data.

That said, if we run this code in Lucee 5.2.9.31 (via CommandBox), we get the following error:

lucee.runtime.exp.ExpressionException: variable [VALUE] doesn't exist


 
 
 

 
 Lucee 5 error referencing NULL value returned from canonicalize() function. 
 
 
 

As you can see, calling canonicalize() on an empty String in Lucee returns NULL. The Null return "destroys" the "value" variable, which, in turn, raises an error when we try to reference it subsequently.

Now, if we run the same code in Adobe ColdFusion 10 or ColdFusion 2018, we get the following output:

VALUE: [ ]

As you can see, in Adobe ColdFusion, calling canonicalize() on an empty String simply returns an empty String and the code continues to function.

For the most part, Lucee CFML and Adobe CFML are compatible. In our conversation work, it's just a matter of sussing-out these tiny differences. We're like 99.99% of the way there.



Reader Comments

@Zachary,

Ah, that's a good point. Since I'm fairly new to Lucee, I wanted to err on the side of the lesser of the two bugs. But, I think you are right - parallel functionality is the more important issue.

Reply to this Comment

@Andrew,

Holy cow, that was fast :D You guys are amazing.

@Zachary,

Gotcha -- I didn't know about dev.lucee.org. Good to know.

Reply to this Comment

Post A Comment

You — Get Out Of My Dreams, Get Into My Comments
Live in the Now
Oops!
NEW: Some basic markdown formatting is now supported: bold, italic, blockquotes, lists, fenced code-blocks. Read more about markdown syntax »
Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.