From de72753798719a5aa56a488d68224fdd74c44c1a Mon Sep 17 00:00:00 2001 From: Zac Spitzer Date: Thu, 20 Jul 2023 16:37:05 +0200 Subject: [PATCH] LDEV-4644 LDEV-4631 backport admin update notifcation improvements https://luceeserver.atlassian.net/browse/LDEV-4644 https://luceeserver.atlassian.net/browse/LDEV-4631 --- .../main/cfml/context/admin/Application.cfc | 1 - .../main/cfml/context/admin/ext.functions.cfm | 93 +++++++++++++------ .../cfml/context/admin/services.update.cfm | 8 +- .../admin/services.update.functions.cfm | 9 ++ core/src/main/cfml/context/admin/update.cfm | 65 +++++++------ .../main/cfml/context/admin/web_functions.cfm | 20 +++- loader/build.xml | 2 +- loader/pom.xml | 2 +- 8 files changed, 140 insertions(+), 60 deletions(-) diff --git a/core/src/main/cfml/context/admin/Application.cfc b/core/src/main/cfml/context/admin/Application.cfc index 7085c50f3b..cf519c4f18 100644 --- a/core/src/main/cfml/context/admin/Application.cfc +++ b/core/src/main/cfml/context/admin/Application.cfc @@ -35,7 +35,6 @@ this.tag.cookie.httpOnly = true; // prevent access to session cookies from javas this.tag.cookie.sameSite = "strict"; this.tag.cookie.path = getAppFolderPath(); - this.xmlFeatures = { externalGeneralEntities: false, secure: true, diff --git a/core/src/main/cfml/context/admin/ext.functions.cfm b/core/src/main/cfml/context/admin/ext.functions.cfm index 993480aaab..701f684036 100644 --- a/core/src/main/cfml/context/admin/ext.functions.cfm +++ b/core/src/main/cfml/context/admin/ext.functions.cfm @@ -4,21 +4,66 @@ - - - - + + function updateAvailable(required struct data, required query extensions ) output="yes" { + + var result=variables.getdataByid( arguments.data.id, arguments.extensions ); + if ( result.count() ==0 ) + return false; + var sort = queryNew( "v,type,vf,extra", "varchar,varchar,varchar,varchar" ); + var r= 0; + + function parseType (v) { + var filterTypes = {"beta": 1, "snapshot" : 1,"rc" : 1, "alpha": 1}; + var type = ( arguments.v contains "-" ) ? listLast( arguments.v, "-" ) : ""; + var extra = ""; + var vv = arguments.v; + if ( type == "" ){ + var suffix = listLast( vv,"." ); + if ( len( suffix ) gt 1 and !isNumeric( suffix[ 1 ] ) ){ + extra = suffix; // i.e .jre8, .odbcj8 + vv = listDeleteAt( vv, listlen( vv,"." ), "." ); + } + } else if ( !structKeyExists( filtertypes, type ) ){ + extra = type & ""; // i.e. -jre8 -jre11 + type = ""; + vv = listFirst( vv, "-" ); + } - - - - + return { + v: vv, + type: type, + extra: extra + }; + } - - + function addVersion(sort, v, installed){ + var meta = parseType( arguments.v ); + if ( arguments.installed.type neq meta.type ) return; + if ( arguments.installed.extra neq meta.extra ) return; + var r = queryAddRow( arguments.sort ); + querySetCell( arguments.sort, "v", variables.toVersionSortable( meta.v ), r ); + querySetCell( arguments.sort, "vf", arguments.v, r ); + querySetCell( arguments.sort, "type", meta.type, r); + querySetCell( arguments.sort, "extra", meta.extra, r); + } + var installed = parseType( arguments.data.version ); + loop array=#result.otherVersions# index="local.i" { + addVersion( sort, i, installed ); + } + addVersion( sort, result.version, installed ); + querySort(sort, "v", "desc"); + + if ( sort.recordcount gt 0 ){ + if ( sort.v[ 1 ] GT variables.toVersionSortable( installed.v ) ) + return sort.vf[ 1 ]; + } + return false; + } + @@ -35,25 +80,13 @@ - - - - - - - - - ",true,true)> - - - @@ -584,16 +617,18 @@ } function toVersionsSorted(required array versions) localMode=true { - var vs = [=]; + var sorted = queryNew("ver,sort"); loop array=arguments.versions item="local.v"{ - vs[toVersionSortable(v)] = v; + row = queryAddRow(sorted); + querySetCell(sorted, "ver", v, row); + querySetCell(sorted, "sort", toVersionSortable(v), row); } - var sorted = structSort(vs,"text", "desc"); - var rtn = [=]; - loop array=sorted item="local.v" { - rtn[v] = vs[v]; + QuerySort(sorted, 'sort', 'desc'); + var result = structNew("linked"); + loop query=sorted { + result[sorted.sort] = sorted.ver; } - return rtn; + return result; } function toVersionSortable(required string version) localMode=true { diff --git a/core/src/main/cfml/context/admin/services.update.cfm b/core/src/main/cfml/context/admin/services.update.cfm index 0432705753..a0b91f308a 100755 --- a/core/src/main/cfml/context/admin/services.update.cfm +++ b/core/src/main/cfml/context/admin/services.update.cfm @@ -183,6 +183,10 @@ //dump(var:versionsStr,expand:false); //dump(var:updateData,expand:false); printError(error); + + currMajor=listFirst(server.lucee.version,"."); + selectedUpdate = getUpdateForMajorVersion(updateData.otherVersions, currMajor ); + @@ -231,7 +235,9 @@ - + + >#stText.services.update.upgradeTo# #i# diff --git a/core/src/main/cfml/context/admin/services.update.functions.cfm b/core/src/main/cfml/context/admin/services.update.functions.cfm index 58c9ac01ad..ae29359c40 100755 --- a/core/src/main/cfml/context/admin/services.update.functions.cfm +++ b/core/src/main/cfml/context/admin/services.update.functions.cfm @@ -51,4 +51,13 @@ return rsp; } + string function getUpdateForMajorVersion( array versions, numeric majorVersion ){ + loop from="#arrayLen(arguments.versions)#" to="1" index="local.v" step="-1" { + if ( listfirst(arguments.versions[ v ],".") eq arguments.majorVersion ){ + return arguments.versions[ v ]; + } + } + return ""; + } + \ No newline at end of file diff --git a/core/src/main/cfml/context/admin/update.cfm b/core/src/main/cfml/context/admin/update.cfm index f7874c54a4..b978c56fb9 100755 --- a/core/src/main/cfml/context/admin/update.cfm +++ b/core/src/main/cfml/context/admin/update.cfm @@ -38,33 +38,47 @@ - + + + + - + - + - + - + - + - + + + + + + + + + + + + @@ -76,9 +90,10 @@ - + + @@ -103,19 +118,21 @@ - - - - - - - - - - - + + sct = {}; + loop list="#extensions.columnlist()#" item="key" { + sct[ key ]=extensions[ key ]; + } + updateVersion= updateAvailable( sct, external ); + if (updateVersion eq "false") + continue; + uid=extensions.id + link=""; + dn=""; + link="#self#?action=ext.applications&action2=detail&id=#uid#"; + - - #extensions.name#
+ - #extensions.name# - #updateVersion# ( #sct.version# )
@@ -164,11 +181,7 @@ @@ -177,7 +190,7 @@ diff --git a/core/src/main/cfml/context/admin/web_functions.cfm b/core/src/main/cfml/context/admin/web_functions.cfm index 2b486532c6..82115e8198 100644 --- a/core/src/main/cfml/context/admin/web_functions.cfm +++ b/core/src/main/cfml/context/admin/web_functions.cfm @@ -361,4 +361,22 @@ function _byteFormatShort(numeric left,numeric right,string suffix){ -
\ No newline at end of file + + + + + /** + * replaces double quote character with two consecutive quote characters + */ + public string function escapeDoubleQuotes(required string input) { + return replace(arguments.input, '"', '""', "all"); + } + + /** + * replaces single quote character with two consecutive quote characters + */ + public string function escapeSingleQuotes(required string input) { + return replace(arguments.input, "'", "''", "all"); + } + + \ No newline at end of file diff --git a/loader/build.xml b/loader/build.xml index 599d1c1439..4b78d8dfdd 100644 --- a/loader/build.xml +++ b/loader/build.xml @@ -2,7 +2,7 @@ - + diff --git a/loader/pom.xml b/loader/pom.xml index 68cf93e39e..290e9809c4 100644 --- a/loader/pom.xml +++ b/loader/pom.xml @@ -3,7 +3,7 @@ org.lucee lucee - 5.3.11.0-SNAPSHOT + 5.3.11.1-SNAPSHOT jar Lucee Loader Build