Posts

Showing posts from 2016

Oh dear, a dodgy old piece of code in ColdFusion 8 style with local scopes!

A seldom used piece of code fell victim to the "new" ColdFusion "Local scope" from CF 9 (Centaur) With an Application.cfc; naturally everything inside it is local'ish when the onRequest exists: <cfcomponent displayname="Application" output="true" hint="Handle the application.">     <cffunction name="OnRequestStart" access="public" returntype="boolean" output="false">         <cfargument name="TargetPage" type="string" required="true"    />         <cfreturn true />     </cffunction>     <cffunction name="OnRequest" access="public" returntype="void" output="true">         <cfargument    name="TargetPage" type="string" required="true" />         <cfinclude template="#arguments.TargetPage#" />         <cfreturn />     </

Lucee 4.5.2 cfhttp inconsistent timeout response with Adobe Coldfusion

Trying to catch a timeout is alwas a problem, particularly on those jumpy sites that are normally ok, but can be offline for an hour or 2 when the owners is asleep! There is a bug here https://luceeserver.atlassian.net/browse/LDEV-80 but it is not quite the same and I do get a correct response if in the example below sleep(4000) was replaced by a=1/0; Suppose a file like so: <cfif structkeyexists(url, "test")>     <cfscript>sleep(4000);</cfscript> <cfelse> <cftry>     <cfhttp timeout="2" url="http://#cgi.http_host##cgi.script_name#?test" throwonerror="true" result="x" />     <cfcatch type="any">        <cfdump var="#x#" />         <cfdump var="#cfcatch#" />     </cfcatch> </cftry> </cfif> Lucee 4.5.2 produces Struct errordetail string while the cfcatch adds in this statusCode string 408 statusText st

Lucee 4.5.2 cfparam null value error with full null support

With cfparam and the full null support (non default behaviour) there is a dodgy impact: Suppose qryDB has a null valued column, and you set a variable to that null value <cfparam name="myVar" default="#qryDB.nullValueColumn#"> This throws an error, same as would happen in this instance; <cfparam name="myVar"> Though the later appears to be inconsistently present in Adobe ColdFusion also; http://blog.adamcameron.me/2013/04/coldfusion-bugs-id-like-to-see-dealt.html

Lucee 4.5.2 cfpdfparam difference with Adobe ColdFusion

Suppose the following on Lucee 4.5.2: <cfset x = 1> <cfdocument format="pdf" pagetype="A4" name="myVar#x#"> <cfdocumentsection> Hi there </cfdocumentsection> </cfdocument> <cfpdf action="merge" destination="RAM:///myPDF.pdf" overwrite="yes">     <cfpdfparam source="#evaluate("myVar#x#")#" /> </cfpdf> <cfcontent file="RAM:///myPDF.pdf" type="application/pdf"> then to check it also runs on Adobe Cf; you'd actually end up with: "ByteArray objects cannot be converted to strings."   The original code for Adobe CF ran with the paramater like so:  <cfpdfparam source="myVar#x#" /> Both sets of documentation list source defined as follows: "Source PDF file to merge. You can specify a PDF variable, a cfdocument variable, or the pathname to a file." This would indicate it is just

Global SQL Procedure, System Objects and sp_ms_marksystemobject

You may come across a need to have a database of utils full of generic procedures which work on indvidual databases (say client databases). You can't pass the database name into the procedure as a parameter and say "use @dbname" in the procedure and dynamic sql sucks. One workaround is to create the procedure in the master database and then mark it as a system object. eg use [master] create procedure sp_doThis // note the sp_ prefix is required begin // etc etc end go exec sp_ms_marksystemobject 'sp_doThis' // second note, this procedure is undocumented, so I wouldn't be relying on this for life or death. use [myotherdb] exec sp_doThis go All done!

Design best practice for an image library

If the library holds data in a raw format (ie a big sized image), then can then make all sorts of algorithms out of that to produce images. Generate different sizes, eg 100x100, 200x400 or what ever is required from the original Generate different types of images, either by conversion (png etc) or type, maybe base 64 for CSS and separate style sheet images for non base64 supporting CSS (like IE8 etc) Overlay another graphic on top (like a sash or otherwise) to generate only 1 image that needs to be retrieved All of this requires the smarts that you allow the original image to have coordinates stored against it as to where the center is or maybe use something like  https://github.com/tapmodo/Jcrop to create and store these coordinates of the box sizes. I've found it quite useful when uploading images through custom application to write the files as (for example) full_raw.png (usually stored in a database somewhere) full100x100.png (resized, re scaled depending how

Nice Table sorter (Jquery)

Ok so there are quite a few out there, but I've never seen one which I've had to do absolutely no customization at all; well done https://editor.datatables.net/ . Very nice exporting to CSV, great sorting, great custom display and filtering (allowing tables to be summed up depending on what you filtered on). Honorable mention http://tablesorter.com/docs/ I used this for quite a while, but the datatables has the exports and filtering which I had to write an extension of for tablesorter.

Diffie-Hellman limit issues with java 1.7 and Connection Failure

Suppose calling a https url. Error is was returning: ErrorDetail    I/O Exception: peer not authenticated Filecontent    Connection Failure Mimetype    Unable to determine MIME type of file. Statuscode    Connection Failure. Status code unavailable. Debugging this ended up with with an error like so: javax.net.ssl.SSLException: java.lang.RuntimeException: Could not generate DH keypair Added certificate of the URL to the cacerts file with keytool No luck Changed to unlimited strength like so http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html No luck Added this to JVM 1.7 config (not sure this is even supported) -Djdk.tls.ephemeralDHKeySize=2048 No luck Tried switching to JVM 1.8 config; -Djdk.tls.ephemeralDHKeySize=2048 No luck Added DH to in java.security disabledAlgorithms jdk.certpath.disabledAlgorithms=MD2 ,DH Bingo Given that Diffle-Hellman key exchange of 1024 can be possibly broken, this is probably not such a bad thing.

JVM 1.7 and Coldfusion and Connection Failure

A lot of connection failures were showing up due to servers upgrading their certificates to the latest and greatest versions (256 bit) which (by the looks of things) weren't really working on Java 1.6 (128bit). Anyway, to upgrade CF 9 to 1.7 (1.8 not supported and the server monitor stopped working if this was done); installed Java 1.7, opened up the jvm.config for ColdFusion and changed the path for java.home. Copy of msvcr100.dll from JDK\bin in JRun4\bin Restarted the service and all went well. Then it fell over! Then I restarted the service. Then it fell over... Turns out, need to remove -XX:MaxPermSize=192m  from the jvm params, else preapre for some see sawing! Also, good idea to use the  -Duser.country= &  -Duser.language= parameters if required, as I ended up constantly getting US set up (despite the OS saying otherwise) Any other Connection Failure issues with these new certificates were resolved by importing missing chains using keytool .

keytool & importing new certificates / missing chains for Java

Everyonce in a  while new root certificates come out that ain't trusted by your server. JRun4\jre\bin\keytool -import -keystore \JRun4\jre\lib\security\cacerts -file \somenewcertificate.crt See these links also for the issues these caused with ColdFusion  https://docs.google.com/document/d/12Ef1SwddMh0oO11TS3lt5E8VGiVCsdI8WmYn8qQLW4c/edit# https://bugbase.adobe.com/index.cfm?event=bug&id=3041494    Remember also if using Coldfusion with a different JVM version, the cacerts is in the JVM version!