Skip to content

Instantly share code, notes, and snippets.

View JamoCA's full-sized avatar

James Moberg JamoCA

View GitHub Profile
@JamoCA
JamoCA / htmlhead_content_fail.cfm
Last active October 31, 2022 17:39
CFHTMLHead content is no longer added after a reset using CFContent.
<!--- 20221028 Starting with CF2021, CFHTMLHead text is no longer added after a reset using CFContent. (Undocumented)
Tweet: https://twitter.com/gamesover/status/1586142456491298816
Gist: https://gist.github.com/JamoCA/a56dfd74aa4ae9dad57747f516d6196a
--->
<cfhtmlhead text="<meta name=""info"" content=""I should be in the HEAD section."">">
<cfcontent type="text/html; charset=UTF-8" reset="true">
<p>View Source (Check for existence of metatag above this line.)</p>
<p>In Adobe ColdFusion 9-2018 & Lucee, the CFHTMLHead text is correctly added. CF2021 fails to add anything after cfcontent.</p>
@JamoCA
JamoCA / attributesTest.cfm
Last active October 20, 2022 15:41
Should a ColdFusion/CFML object change (by reference) when being passed as an argument/attribute collection parameter?
<cfparam name="attributes.var1" default="value1">
<cfparam name="attributes.var2" default="value2">
@JamoCA
JamoCA / getClass-test.cfm
Last active October 7, 2022 21:50
Using ColdFusion Safe Navigation to identify scope class names. CFML
<!--- 2022-10-07 by James Moberg / SunStar Media
Requires ColdFusion 2016+ or Lucee CFML
GIST: https://gist.github.com/JamoCA/f2ae1a8140f857aa4fc264a5474b56ad
--->
<h2>Identify Scope Class Names using ColdFusion Safe Navigation Operator</h2>
<cfoutput>
application = #application?.getClass()?.getName()#<br>
form = #form?.getClass()?.getName()#<br>
@JamoCA
JamoCA / getScopedVariable-udf.cfm
Last active October 7, 2022 23:06
This getScopedVariable UDF tests to determine if a valid scope + variable exists w/o throwing an error. If non-existent, a default value is returned.
<!--- 2022-10-07 getScopedVariable UDF by James Moberg / SunStar Media
GIST: https://gist.github.com/JamoCA/7e544f1488a703d868cecc2b7ae5c2ed
BLOG: https://dev.to/gamesover/safely-fetching-scoped-variables-while-avoiding-scope-injection-2ee3
TWEET: https://twitter.com/gamesover/status/1578522152600424449
This getScopedVariable UDF tests to determine if a valid scope + variable exists w/o throwing an error.
If non-existent, a default value is returned. --->
<cfscript>
// This is only test code.
// The reason for this is to 1) attempt to validate scoped variables when session, client or application variables aren't enabled
@JamoCA
JamoCA / justNumericList.cfm
Last active October 6, 2022 17:11
justNumericList - Filters a text string to return int/float numeric values w/optional min/max restrictions. (ColdFusion / CFML)
<cfscript>
/* justNumericList - Filters a text string to return int/float numeric values w/optional min/max restrictions.
* 2022-10-06
* GIST: https://gist.github.com/JamoCA/92ddc1d7cf04aa021321ba7e9185f16f
* Forked from https://cflib.org/udf/justNumericList by James Moberg / SunStar Media
* Refactor/modernized (CF2016+ or Lucee required);
* Parameters:
* @param nList List to filter. (Required)
* @param strDelim List delimiter. (default: ",")
* @param integersOnly Boolean to restrict returned list to only signed integers (default: false)
@JamoCA
JamoCA / areBracesValid.cfm
Last active November 8, 2022 16:38
areBracesValid UDF for ColdFusion/CFML - Useful to determine if braces are correctly matched before processing. Helps reduce SQLi.
<!--- areBracesValid ColdFusion/CFML UDF (2022-09-16)
Useful to determine if braces are correctly matched before processing. Helps reduce SQLi.
By James Moberg - SunStar Media https://www.sunstarmedia.com/
Gist: https://gist.github.com/JamoCA/a35ffaabc00e0339a9996e27825159a7
Blog: https://dev.to/gamesover/arebracesvalid-udf-for-coldfusioncfml-21fg
Tweet: https://twitter.com/gamesover/status/1570911352138641408
20220918 Updated to use single refind/replaceAll expressions
20221108 Updated to use "while" instead of cfloop/condition (which isn't supported by Lucee in cfscript.)
--->
<cfscript>
@JamoCA
JamoCA / getIntsFromRangeString.cfm
Last active September 20, 2022 16:22
getIntsFromRangeString UDF for ColdFusion / CFML - Parses integers using min/max rules to generate sorted array of INTs and visual display summarizing string.
<!--- getIntsFromRangeString 2022-9-013
getIntsFromRangeString UDF for ColdFusion / CFML
Parses integers using min/max rules to generate sorted array of INTs and visual display summarizing string.
By James Moberg / SunStar Media https://www.sunstarmedia.com/
Blog: https://dev.to/gamesover/getintsfromrangestring-udf-for-coldfusion-n74
Gist: https://gist.github.com/JamoCA/db753001d64a6fd4d46d2f591769c589
Tweet: https://twitter.com/gamesover/status/1569843303084101633
2022-09-15 Add support to parse "INT+" syntax.
2022-09-15 Add support for LT, LTE, GT and GTE syntax / Use byte temp value when generating struct of unique INTs
2022-09-15 Remove default minInt/maxInt arguments. (Assuming a default maximum of 2147483647 = extremely poor performance.)
@JamoCA
JamoCA / custom-tag-test.cfm
Last active July 18, 2022 19:21
Testing nuance when calling a CFM-based custom tag using cfscript. #coldfusion #cfml
<!--- 20220718 CustomTag CFScript "Nuance"
Blog: https://dev.to/gamesover/customtag-cfscript-nuance-4nig
Tweet: https://twitter.com/gamesover/status/1549111965523386368
--->
<p>This executes the custom tag only one (1) time.</p>
<cf_helloCount>
<P>When called from cfscript, this CFM-based custom tag is executed twice.</p>
@JamoCA
JamoCA / exiv2.cfm
Last active August 3, 2022 02:00
Extract image metadata (Exif, IPTC, XMP metadata and ICC Profile) using Exiv2 and ColdFusion / CFML
<cfscript>
/* 2016-02-16 Exiv2 (shared on 2022-07-06)
By James Moberg - SunStar Media
Requires command-line version of Exiv2 http://www.exiv2.org/
All data returned in a struct. Based on different filetypes & available metadata, keys may not always exist.
Requirements: CF2016u3+ or Lucee 4.5+
Blog: https://dev.to/gamesover/use-exiv2-to-extract-gps-data-from-images-using-cfml-3maa
Tweet: https://twitter.com/gamesover/status/1544747532881903616
Forum: https://community.adobe.com/t5/coldfusion-discussions/using-imagegetexifmetadata-to-try-to-get-gps-coordinates-of-an-image/m-p/13053016
*/
@JamoCA
JamoCA / cf_timer.cfm
Last active August 3, 2022 01:54
CF_Timer... like Adobe's built-in CFTimer, but without requiring admin IP rule and also including nanoTime
<cfsilent><!---
CF_Timer: Like Adobe's built-in CFTimer, but without requiring admin IP rule and also including nanoTime.
Author: James Moberg
Date: 9/20/2013
Shared: 7/3/2022
Notes: Called like cftimer but without enabling debugging. (NOTE: "debug" mode not supported.)
Types: outline (default)
Credit: Initial "myTimer" CFTag by Chris Phillips ( http://www.cfchris.com/cfchris/index.cfm/2007/4/5/My-CFTIMER-Custom-Tag )
Adobe CFTimer Docs: https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/tags-t/cftimer.html
Blog Entry: https://dev.to/gamesover/cftimer-no-debugging-ip-address-required-introducing-nanotime-1k8h