From a29e4fd5904da5f2d29dc77da9baac76a14ca266 Mon Sep 17 00:00:00 2001 From: KarolDawidziuk Date: Wed, 26 Jun 2024 17:20:37 +0200 Subject: [PATCH 1/3] Update version-check --- core/ckeditor_version-check.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/core/ckeditor_version-check.js b/core/ckeditor_version-check.js index ec59d31455c..64e03a9de52 100644 --- a/core/ckeditor_version-check.js +++ b/core/ckeditor_version-check.js @@ -166,12 +166,17 @@ return null; } + var minor = parseInt( parts[ 1 ] ), + patch = parseInt( parts[ 2 ] ), + isIts = !!parts[ 3 ], + name = '4.' + minor + '.' + patch + ( isIts ? '-lts' : '' ); + return { - original: version, + name: name, major: 4, - minor: Number( parts[ 1 ] ), - patch: Number( parts[ 2 ] ), - isLts: !!parts[ 3 ] + minor: minor, + patch: patch, + isLts: isIts }; } From a757c3da466ca01e76505af4b446b3dcde0ae9f5 Mon Sep 17 00:00:00 2001 From: KarolDawidziuk Date: Tue, 6 Aug 2024 12:04:18 +0200 Subject: [PATCH 2/3] Rename remaining `original` to `name` --- core/ckeditor_version-check.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core/ckeditor_version-check.js b/core/ckeditor_version-check.js index 64e03a9de52..3e2ef75eabe 100644 --- a/core/ckeditor_version-check.js +++ b/core/ckeditor_version-check.js @@ -52,7 +52,7 @@ try { var request = new XMLHttpRequest(), - requestUrl = apiUrl + '?v=' + encodeURIComponent( versionInfo.current.original ); + requestUrl = apiUrl + '?v=' + encodeURIComponent( versionInfo.current.name ); request.onreadystatechange = function() { if ( request.readyState === 4 && request.status === 200 ) { @@ -79,8 +79,8 @@ return; } - var notificationMessage = editor.lang.versionCheck.notificationMessage.replace( '%current', versionInfo.current.original ). - replace( '%latest', versionInfo.latest.original ). + var notificationMessage = editor.lang.versionCheck.notificationMessage.replace( '%current', versionInfo.current.name ). + replace( '%latest', versionInfo.latest.name ). replace( /%link/g, upgradeLink ), isNotificationAvailable = 'notification' in editor.plugins; @@ -102,8 +102,8 @@ consoleErrorDisplayed = true; - var consoleMessage = editor.lang.versionCheck.consoleMessage.replace( '%current', versionInfo.current.original ). - replace( '%latest', versionInfo.latest.original ). + var consoleMessage = editor.lang.versionCheck.consoleMessage.replace( '%current', versionInfo.current.name ). + replace( '%latest', versionInfo.latest.name ). replace( /%link/g, upgradeLink ); console.error( consoleMessage ); @@ -133,8 +133,8 @@ msg = lang.aboutDialogInsecureMessage; } - return msg.replace( '%current', versionInfo.current.original ). - replace( '%latest', versionInfo.latest.original ). + return msg.replace( '%current', versionInfo.current.name ). + replace( '%latest', versionInfo.latest.name ). replace( /%link/g, upgradeLink ); } From e35bbadc15e2ae76e39b3fc963b851ecc0da4b28 Mon Sep 17 00:00:00 2001 From: KarolDawidziuk Date: Thu, 8 Aug 2024 16:25:56 +0200 Subject: [PATCH 3/3] Wrap `onreadystatechange` function body with try catch block --- core/ckeditor_version-check.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/core/ckeditor_version-check.js b/core/ckeditor_version-check.js index 3e2ef75eabe..c63b6308b77 100644 --- a/core/ckeditor_version-check.js +++ b/core/ckeditor_version-check.js @@ -56,14 +56,16 @@ request.onreadystatechange = function() { if ( request.readyState === 4 && request.status === 200 ) { - var response = JSON.parse( request.responseText ); + try { + var response = JSON.parse( request.responseText ); - versionInfo.latest = parseVersion( response.latestVersion ); - versionInfo.secure = parseVersion( response.secureVersion ); - versionInfo.isLatest = isLatestVersion(); - versionInfo.isSecure = isSecureVersion(); + versionInfo.latest = parseVersion( response.latestVersion ); + versionInfo.secure = parseVersion( response.secureVersion ); + versionInfo.isLatest = isLatestVersion(); + versionInfo.isSecure = isSecureVersion(); - callback(); + callback(); + } catch ( e ) {} } };