Skip to main content

James Moberg

Member since Dec 11, 2008

Recent Blog Comments By James Moberg

  • Sanity Checking HTTP Method Used After Location() Call In ColdFusion

    Posted on Feb 19, 2025 at 5:28 PM

    Have you tested to identify how other clients handle 303 redirects? (ie, CFHTTP, CFX_HTTP5, CURL, WGET, etc?) I used CURL (on Windows) with the location flag enabled to connect to an IIS web server: curl -vv -L -X POST "https://www.mywebsite.com/redirect-test.cfm" -d "useSt... read more »

  • Strange ___IMPLICITARRYSTRUCTVAR Behavior In ColdFusion

    Posted on Jan 7, 2025 at 12:03 AM

    I've been using the "local" scope instead of "var" for functions, but haven't written many closures due to compatibility with past versions of ACF. Does this perform the same function? (If so, there's no error in CF2023.) https://gist.github.com/JamoCA/4489707b2aa53f9a... read more »

  • Using CFLoop To Iterate Over A File Line-By-Line In ColdFusion

    Posted on Dec 7, 2024 at 7:59 PM

    When processing the file has been completed (after the fileClose operation), how long do you have the process wait before moving or deleting the file? If a file move or delete is performed immediately afterwards (on Windows), I usually encounter an error indicating that the file is "s... read more »

  • Ask Ben: Sorting Quasi-Numeric Values Like 4K And 3M In ColdFusion

    Posted on Dec 6, 2024 at 5:10 PM

    I do something similar, but often my data is in a query. I'll pass it to a function that: accepts a query object adds a new numeric column (if it doesn't already exist) iterate over the rows to update the value to be sorted based on the intrinsic needs of the website return ... read more »

  • Using fileGetMimeType() To Determine File Type In ColdFusion

    Posted on Nov 20, 2024 at 11:07 PM

    After your article, I've started comparing my UDF's static configuration of extensions & MIME types. One the first mismatches was the .ai extension for Adobe Illustrator. My UDF returns application/postscript and Adobe's BIF returns application/illustrator . This article from 2022... read more »

  • Using fileGetMimeType() To Determine File Type In ColdFusion

    Posted on Nov 16, 2024 at 6:53 PM

    "Trust, but verify." -Russian proverb My mime type unit test contains 409 different file extensions, but I don't use any physical test files. The fileGetMimeType function requires a physical file even when the 2nd parameter is false. (If false & detection is based solely on ... read more »

  • Building A Moment-Inspired .fromNow() Date Formatting Method In ColdFusion

    Posted on Nov 15, 2024 at 10:30 PM

    Are you interested in more moment.js functionality for ColdFusion? Check out the 7yr old momentcfc library (from Adam Tuttle) that's still compatible w/CF10 & 11. It has a fromNow method. I'm not sure about millisecond support (that something that I care about too.)... read more »

  • Adobe ColdFusion Parses JSON Into Non-Ordered Structs

    Posted on Aug 7, 2024 at 9:59 PM

    I've been using JSONUtil since ColdFusion 8/9. I modified the deserializeJSON method to explicitly generated ordered structs so that the struct keys are in the same order as the original JSON string. https://github.com/cfcommunity/jsonutil The reason for this? We save data in JSON format... read more »

  • Building A Magic Link Passwordless Login In ColdFusion

    Posted on Jun 20, 2024 at 7:10 PM

    I've been using a UDF that I believe provides a similar solution and it relies on cachePut/cacheGet so that no data is passed in the token. It automatically expires on the server after the duration has passed. This approach is only practical on a monolith web application unless the cache is ... read more »

  • Pretty-Printing JSON Using GSON In Lucee CFML 5.3.9.141

    Posted on May 2, 2024 at 12:02 AM

    To prevent HTML escaping (and make your JSON potentially HTML unsafe), use disableHtmlEscaping . The disableHtmlEscaping() method tells Gson not to escape HTML characters such as < , > , & , = , and ' . var gson = createObject("java", "com.google.g... read more »

  • Creating A Marquee Effect With CSS Animations

    Posted on Dec 1, 2023 at 5:49 PM

    This could be nightmarish if used in abundance on a webpage that has lots of unintended truncated/overflowed content. I think I'd switch it up and add a visual indicator on any elements that use this (due to overflow) and then scroll while hovering/mouseover and perhaps reset to original upo... read more »

  • Enforcing The HTTP Request Method In ColdFusion

    Posted on Oct 24, 2023 at 4:50 PM

    We do use cfparam to predefine all expected form parameters, but only after the initial request has met the requirements of the structkeyexists() validation.... read more »

  • Enforcing The HTTP Request Method In ColdFusion

    Posted on Oct 24, 2023 at 4:47 PM

    There was a CF4 custom tag called CF_FormURL2Attributes that would copy all FORM & URL variables to a generic "attributes" scope. (I believe that it also accepted path-based values from SEO-friendly URLs.) I don't see this CFTag available anywhere online anymore. We used it b... read more »

  • Enforcing The HTTP Request Method In ColdFusion

    Posted on Oct 24, 2023 at 4:34 PM

    We validate the request method & test for at least one of the required form variables. If this condition is not met, we re-display the form. (If a form post was used and not valid, we display a pretty inline error message.) Something like this... (NOTE: This is generic.) isFormPost = ... read more »

  • jSoup Error: Index Out Of Bounds For Length

    Posted on Oct 20, 2023 at 4:30 PM

    A fix for this exact issue (1.16.2) was released last night. https://jsoup.org/news/release-1.16.2 Your blog is also listed in the notes: https://github.com/jhy/jsoup/issues/2013 Appending a node back to its original Element after empty() would throw an Index out of bounds ex... read more »

  • Understanding The TrimWhitespace() Function In Lucee CFML

    Posted on Oct 10, 2023 at 9:48 PM

    The java source for Lucee's trimWhitespace() function is available at: https://github.com/lucee/Lucee/blob/8554dddfffcdc5fdb0c4d9f298c61bc0d6c837d2/core/src/main/java/lucee/runtime/functions/string/TrimWhiteSpace.java#L9 It looks like it filters some common ASCII7 space characters, but not ... read more »

  • Which Whitespace Characters Does trim() Remove In ColdFusion

    Posted on Sep 19, 2023 at 8:49 PM

    I've seen characters added when data is copied from one Microsoft program to another. Excel often adds unwanted carriage returns. I've logged some hack attempts that use unsafe spaces in an attempt to bypass keyword blocklists. (ie, it looks the same but won't get blocked.) Even worse IMH... read more »

  • Which Whitespace Characters Does trim() Remove In ColdFusion

    Posted on Sep 19, 2023 at 4:46 PM

    I ran into issues with NBSPs in Excel files. Clients use Excel to import data into their databases and may records weren't matching because trailing non-breaking spaces were in some of the cells and they weren't able to be trimmed using CFML or SQL functions. I use VSCode with this extension... read more »

  • ColdFusion Custom Tags Can Use Dashed Attributes

    Posted on May 12, 2023 at 6:44 PM

    Passing strings that fail isvalid("variablename") work when passed as parameters to CFTags using EOL versions of ACF, like CF2016... but using the bracket notation with CFPARAM throws an error. For better cross-platform support, the ternary operator works. This is what I've had to... read more »

  • The Elvis / Null Coalescing Operator Can Sometimes Replace The Safe Navigation Operator In Lucee CFML 5.3.6.61

    Posted on Mar 24, 2022 at 4:47 PM

    It's best to avoid (as commented here two years later): https://www.bennadel.com/blog/4231-fundamental-differences-in-elvis-operator-between-adobe-coldfusion-and-lucee-cfml.htm SUMMARY: Using Adobe ColdFusion, if foo.bar.baz exists & can be evaluated as falsey , it will use the fallb... read more »

I believe in love. I believe in compassion. I believe in human rights. I believe that we can afford to give more of these gifts to the world around us because it costs us nothing to be decent and kind and understanding. And, I want you to know that when you land on this site, you are accepted for who you are, no matter how you identify, what truths you live, or whatever kind of goofy shit makes you feel alive! Rock on with your bad self!
Ben Nadel