Thanks...that makes for interesting reading. I've seen plenty about migrating from CF5 to CFMX but nothing coming the other way. I can think of a few scenarios where this will be useful information.
Cheers Will -----Original Message----- From: Gyrus [mailto:[EMAIL PROTECTED]] Sent: 04 December 2002 12:04 To: CF-Talk Subject: CFMX > CF5: notes on backwards compatibility I just uploaded an application I've been developing locally on a CFMX box to a CF5 server we have. Of course I've been careful not to use any MX-specific tags and functions, but there were several problems in backwards-compatibility that I thought I'd document here, hopefully of use to others. Naturally, let me know if I've missed anything about these issues! Also, is there anywhere compiling this sort of info? --------------------------- INLINE EXPRESSIONS Code such as: <a href="index.cfm?action=articles.view&itemID=#URL.itemID#&pg=#(URL.pg +1)#">Next page</a> seems to work fine on CFMX, but chokes on CF5. Using #Evaluate(URL.pg+1)# works, but in other similar instances it didn't seem to help. Given this, and the general "Whoah! Don't use that!" attitude I've noticed towards Evaluate(), I set a temp var in each instance to equal the expression and output the var. --------------------------- CFDEFAULTCASE CFMX doesn't seem to mind if you slip CFDEFAULTCASE in *before* any CFCASE statements, which I did several times without thinking. CF5 does - the default always needs to be last in the list. --------------------------- RESERVED WORDS In CFMX, I had to change this SQL filter: WHERE section = '#attributes.section#' to this: WHERE [section] = '#attributes.section#' "section" being a reserved word and square brackets escaping it. However, CF5 chokes on the square brackets - doesn't want them at all. So I ended up with: <cfif Val(Left(Server.ColdFusion.ProductVersion, 1)) LT 6> WHERE section = '#attributes.section#' <cfelse> WHERE [section] = '#attributes.section#' </cfif> --------------------------- UNICODE SUPPORT I was highly mystified when a CF-processed link HREF came through on the CF5 server with all the "a"s replaced with "s-circumflex" characters. The link was built using a function I wrote called HTMLSafe(), based on ConvertEntity() from cflib.org. I had changed the code so that the list of "bad" characters to match was built using the Chr() function. Using CFMX, for instance, #Chr(353)# will match s-circumflex, which I replaced with š. Characters above 255 in CF5, however, repeat pre-255 characters, and #Chr(353)# will match "a". Hence, all my "a"s were replaced with š, which display in the browser as s-circumflex. I'm no whizz with the issues involved here - maybe someone can explain it better than me! - but FWIW, here's the revised function I came up with to handle the majority of special characters and match them properly depending on the server version: /** * Makes a string of text safe for HTML output. * * @param string The string to format. * @param [stripHTML] Converts < and > to < and >. Default * is TRUE. * @return Returns a string. * @author [EMAIL PROTECTED] * @version 1 October 9, 2002 * @inspiration Mike Gillespie ([EMAIL PROTECTED]) * http://www.cflib.org/udf.cfm?ID=664 */ function HTMLSafe(string) { // Initialise var badChars = """,&,#Chr(161)#,#Chr(162)#,#Chr(163)#,#Chr(164)#,#Chr(165)#,#Chr(166)#,#Chr (167)#,#Chr(168)#,#Chr(169)#,#Chr(170)#,#Chr(171)#,#Chr(172)#,#Chr(173)#,#Ch r(174)#,#Chr(175)#,#Chr(176)#,#Chr(177)#,#Chr(178)#,#Chr(179)#,#Chr(180)#,#C hr(181)#,#Chr(182)#,#Chr(183)#,#Chr(184)#,#Chr(185)#,#Chr(186)#,#Chr(187)#,# Chr(188)#,#Chr(189)#,#Chr(190)#,#Chr(191)#,#Chr(215)#,#Chr(247)#,#Chr(192)#, #Chr(193)#,#Chr(194)#,#Chr(195)#,#Chr(196)#,#Chr(197)#,#Chr(198)#,#Chr(199)# ,#Chr(200)#,#Chr(201)#,#Chr(202)#,#Chr(203)#,#Chr(204)#,#Chr(205)#,#Chr(206) #,#Chr(207)#,#Chr(208)#,#Chr(209)#,#Chr(210)#,#Chr(211)#,#Chr(212)#,#Chr(213 )#,#Chr(214)#,#Chr(216)#,#Chr(217)#,#Chr(218)#,#Chr(219)#,#Chr(220)#,#Chr(22 1)#,#Chr(222)#,#Chr(223)#,#Chr(224)#,#Chr(225)#,#Chr(226)#,#Chr(227)#,#Chr(2 28)#,#Chr(229)#,#Chr(230)#,#Chr(231)#,#Chr(232)#,#Chr(233)#,#Chr(234)#,#Chr( 235)#,#Chr(236)#,#Chr(237)#,#Chr(238)#,#Chr(239)#,#Chr(240)#,#Chr(241)#,#Chr (242)#,#Chr(243)#,#Chr(244)#,#Chr(245)#,#Chr(246)#,#Chr(248)#,#Chr(249)#,#Ch r(250)#,#Chr(251)#,#Chr(252)#,#Chr(253)#,#Chr(254)#,#Chr(255)#"; var goodChars = "",&,¡,¢,£,¤,¥,¦,§,¨,&c opy;,ª,«,¬,­,®,¯,°,±,²,³,&a cute;,µ,¶,·,¸,¹,º,»,¼,½ ;,¾,¿,×,÷,À,Á,Â;,Ã,&Au ml;,Å,Æ,Ç,È,É,Ê,Ë,Ì,&Iacu te;,Î,Ï,Ð,Ñ,Ò,Ó,Ô,Õ,Ö, Ø,Ù,Ú,Û,Ü,Ý,Þ,ß,à, á,â,ã,ä,å,æ,ç,è,é, ê,ë,ì,í,î,ï,ð,ñ,ò,&oac ute;,ô,õ,ö,ø,ù,ú,û,ü,&yacu te;,þ,ÿ,&##338;,&##339;,&##352;,&##353;,&##376;,&##710;,&##732;,& ##8206;,&##8207;,&##8211;,&##8212;,&##8216;,&##8217;,&##8218;,&##8220;,&##82 21;,&##8222;,&##8224;,&##8225;,&##8240;,&##8249;,&##8250;,&##8364;,<sup><sma ll>TM</small></sup>"; var stripHTML = TRUE; if (request.serverVersion LT 6) { // Pre-MX/Unicode matches badChars = "#badChars#,#Chr(140)#,#Chr(156)#,#Chr(138)#,#Chr(154)#,#Chr(159)#,#Chr(136) #,#Chr(150)#,#Chr(151)#,#Chr(145)#,#Chr(146)#,#Chr(130)#,#Chr(147)#,#Chr(148 )#,#Chr(132)#,#Chr(134)#,#Chr(135)#,#Chr(137)#,#Chr(139)#,#Chr(155)#,#Chr(12 8)#,#Chr(153)#"; } else { // MX/Unicode matches badChars = "#badChars#,#Chr(338)#,#Chr(339)#,#Chr(352)#,#Chr(353)#,#Chr(376)#,#Chr(710) #,#Chr(8211)#,#Chr(8212)#,#Chr(8216)#,#Chr(8217)#,#Chr(8218)#,#Chr(8220)#,#C hr(8221)#,#Chr(8222)#,#Chr(8224)#,#Chr(8225)#,#Chr(8240)#,#Chr(8249)#,#Chr(8 250)#,#Chr(8364)#,#Chr(8482)#"; } if (ArrayLen(Arguments) GT 1 AND NOT Arguments[2]) { stripHTML = FALSE; } // Return immediately if blank string if (NOT Len(Trim(string))) { return string; } // If stripping HTML, replace angle brackets if (stripHTML) { badChars = "<,>" & badChars; goodChars = "<,>" & goodChars; } else { // Otherwise, remove quotes from auto-replace lists badChars = ListDeleteAt(badChars, 1); goodChars = ListDeleteAt(goodChars, 1); } // Do replacing string = ReplaceList(string, badChars, goodChars); if (NOT stripHTML) { // Manually replace quotes if keeping HTML in order to avoid replacing those inside tags while (REFind(">([^""<]*)""([^<]*)<", string) NEQ 0) { string = REReplace(string, ">([^""<]*)""([^<]*)<", ">\1"\2<", "ALL"); } } // Return result return string; } ---------------------------------- Hope this is useful, any comments welcome! Gyrus [EMAIL PROTECTED] work: http://www.tengai.co.uk play: http://www.norlonto.net PGP key available ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting.