From 6546249d448cbbe01e27514535312f0726ec9c83 Mon Sep 17 00:00:00 2001 From: sergeyteleshev Date: Thu, 5 Sep 2024 12:52:00 +0200 Subject: [PATCH 01/17] CB-5578 handles url for redirect after custom domain is being deleted --- webapp/packages/core-utils/src/isValidUrl.ts | 13 +------------ webapp/packages/core-website/src/WebsiteLinks.ts | 1 + 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/webapp/packages/core-utils/src/isValidUrl.ts b/webapp/packages/core-utils/src/isValidUrl.ts index 7c7e07a6f1..216fe35198 100644 --- a/webapp/packages/core-utils/src/isValidUrl.ts +++ b/webapp/packages/core-utils/src/isValidUrl.ts @@ -6,17 +6,6 @@ * you may not use this file except in compliance with the License. */ -// test freezes with '5999999999999000000000000000000000000000000' -const urlPattern = new RegExp( - '^(https?:\\/\\/)?' + // protocol - '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // domain name - '((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address - '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path - '(\\?[;&a-z\\d%_.~+=-]*)?' + // query string - '(\\#[-a-z\\d_]*)?$', - 'i', -); // fragment locator - export function isValidUrl(value: string): boolean { - return value.startsWith('https://') || value.startsWith('http://'); + return new RegExp(/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/).test(value); } diff --git a/webapp/packages/core-website/src/WebsiteLinks.ts b/webapp/packages/core-website/src/WebsiteLinks.ts index db76509631..428bde739c 100644 --- a/webapp/packages/core-website/src/WebsiteLinks.ts +++ b/webapp/packages/core-website/src/WebsiteLinks.ts @@ -6,6 +6,7 @@ * you may not use this file except in compliance with the License. */ export class WebsiteLinks { + static ROOT_PAGE = 'https://dbeaver.com/'; static DATA_EDITOR_DOCUMENTATION_PAGE = 'https://dbeaver.com/docs/cloudbeaver/Data-editor/'; static SQL_EDITOR_DOCUMENTATION_PAGE = 'https://dbeaver.com/docs/cloudbeaver/SQL-Editor/'; static SERVER_CONFIGURATION_RESOURCE_QUOTAS_PAGE = 'https://dbeaver.com/docs/cloudbeaver/Server-configuration/#resource-quotas'; From 7a08dcdca8c67cd44c9cec231f1426eda4df660b Mon Sep 17 00:00:00 2001 From: sergeyteleshev Date: Thu, 5 Sep 2024 16:02:36 +0200 Subject: [PATCH 02/17] CB-5578 reverts isValidUrl --- webapp/packages/core-utils/src/isValidUrl.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/webapp/packages/core-utils/src/isValidUrl.ts b/webapp/packages/core-utils/src/isValidUrl.ts index 216fe35198..7c7e07a6f1 100644 --- a/webapp/packages/core-utils/src/isValidUrl.ts +++ b/webapp/packages/core-utils/src/isValidUrl.ts @@ -6,6 +6,17 @@ * you may not use this file except in compliance with the License. */ +// test freezes with '5999999999999000000000000000000000000000000' +const urlPattern = new RegExp( + '^(https?:\\/\\/)?' + // protocol + '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // domain name + '((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address + '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path + '(\\?[;&a-z\\d%_.~+=-]*)?' + // query string + '(\\#[-a-z\\d_]*)?$', + 'i', +); // fragment locator + export function isValidUrl(value: string): boolean { - return new RegExp(/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/).test(value); + return value.startsWith('https://') || value.startsWith('http://'); } From 1d262ce7b62145802b3f82749b3522042ee8b82a Mon Sep 17 00:00:00 2001 From: sergeyteleshev Date: Thu, 5 Sep 2024 17:50:03 +0200 Subject: [PATCH 03/17] CB-5578 pr fixes --- webapp/packages/core-blocks/src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/webapp/packages/core-blocks/src/index.ts b/webapp/packages/core-blocks/src/index.ts index 6dd8a53241..f8de9e495e 100644 --- a/webapp/packages/core-blocks/src/index.ts +++ b/webapp/packages/core-blocks/src/index.ts @@ -10,6 +10,7 @@ export * from './CommonDialog/CommonDialog/CommonDialogFooter'; export * from './CommonDialog/CommonDialog/CommonDialogHeader'; export * from './CommonDialog/CommonDialog/CommonDialogWrapper'; export * from './CommonDialog/ConfirmationDialog'; +export { default as ConfirmationDialogStyles } from './CommonDialog/ConfirmationDialog.module.css'; export * from './CommonDialog/ConfirmationDialogDelete'; export * from './CommonDialog/RenameDialog'; export * from './CommonDialog/DialogsPortal'; From 27a6137760ca5a2287007108be9eafd0972cf561 Mon Sep 17 00:00:00 2001 From: sergeyteleshev Date: Fri, 13 Sep 2024 20:15:11 +0200 Subject: [PATCH 04/17] CB-5578 fixes for QA --- webapp/packages/core-utils/src/isValidUrl.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/webapp/packages/core-utils/src/isValidUrl.ts b/webapp/packages/core-utils/src/isValidUrl.ts index 7c7e07a6f1..3a18f9646b 100644 --- a/webapp/packages/core-utils/src/isValidUrl.ts +++ b/webapp/packages/core-utils/src/isValidUrl.ts @@ -20,3 +20,7 @@ const urlPattern = new RegExp( export function isValidUrl(value: string): boolean { return value.startsWith('https://') || value.startsWith('http://'); } + +export function isValidWebsiteUrl(value: string): boolean { + return urlPattern.test(value); +} From 60c543ed81db0439770affa4682c2198a3b77f83 Mon Sep 17 00:00:00 2001 From: sergeyteleshev Date: Thu, 19 Sep 2024 16:43:16 +0200 Subject: [PATCH 05/17] CB-5578 fixes for redirect on server url in custom certificate deletion --- webapp/packages/core-utils/src/isValidUrl.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/webapp/packages/core-utils/src/isValidUrl.ts b/webapp/packages/core-utils/src/isValidUrl.ts index 3a18f9646b..02da512738 100644 --- a/webapp/packages/core-utils/src/isValidUrl.ts +++ b/webapp/packages/core-utils/src/isValidUrl.ts @@ -17,10 +17,12 @@ const urlPattern = new RegExp( 'i', ); // fragment locator +const serverUrlPattern = /^(https:\/\/)?(localhost|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(:\d+)?(\/.*)?$/i; + export function isValidUrl(value: string): boolean { return value.startsWith('https://') || value.startsWith('http://'); } -export function isValidWebsiteUrl(value: string): boolean { - return urlPattern.test(value); +export function isValidServerUrl(value: string): boolean { + return serverUrlPattern.test(value); } From b27b153c75eee506bd22b766e8484b84ad5e1a3d Mon Sep 17 00:00:00 2001 From: sergeyteleshev Date: Tue, 24 Sep 2024 14:24:55 +0200 Subject: [PATCH 06/17] CB-5578 fix import --- webapp/packages/core-blocks/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/packages/core-blocks/src/index.ts b/webapp/packages/core-blocks/src/index.ts index 1ead9fb690..5ae5eeb067 100644 --- a/webapp/packages/core-blocks/src/index.ts +++ b/webapp/packages/core-blocks/src/index.ts @@ -9,7 +9,7 @@ export * from './CommonDialog/CommonDialog/CommonDialogBody.js'; export * from './CommonDialog/CommonDialog/CommonDialogFooter.js'; export * from './CommonDialog/CommonDialog/CommonDialogHeader.js'; export * from './CommonDialog/CommonDialog/CommonDialogWrapper.js'; -export * from './CommonDialog/ConfirmationDialog'; +export * from './CommonDialog/ConfirmationDialog.js'; export { default as ConfirmationDialogStyles } from './CommonDialog/ConfirmationDialog.module.css'; export * from './CommonDialog/ConfirmationDialogDelete.js'; export * from './CommonDialog/RenameDialog.js'; From 897ea42f52911af0c4ba0cfe263417dc9b3b6c88 Mon Sep 17 00:00:00 2001 From: sergeyteleshev Date: Tue, 24 Sep 2024 15:29:20 +0200 Subject: [PATCH 07/17] CB-5578 creates isValidServer file --- webapp/packages/core-utils/src/index.ts | 1 + webapp/packages/core-utils/src/isValidServerUrl.ts | 12 ++++++++++++ webapp/packages/core-utils/src/isValidUrl.ts | 6 ------ 3 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 webapp/packages/core-utils/src/isValidServerUrl.ts diff --git a/webapp/packages/core-utils/src/index.ts b/webapp/packages/core-utils/src/index.ts index 9344e0c195..70380e26a1 100644 --- a/webapp/packages/core-utils/src/index.ts +++ b/webapp/packages/core-utils/src/index.ts @@ -56,6 +56,7 @@ export * from './TextTools.js'; export * from './throttle.js'; export * from './uuid_.js'; export * from './isValidUrl.js'; +export * from './isValidServerUrl.js'; export * from './isImageFormat.js'; export * from './getCookies.js'; export * from './getUniqueName.js'; diff --git a/webapp/packages/core-utils/src/isValidServerUrl.ts b/webapp/packages/core-utils/src/isValidServerUrl.ts new file mode 100644 index 0000000000..9744b8f4da --- /dev/null +++ b/webapp/packages/core-utils/src/isValidServerUrl.ts @@ -0,0 +1,12 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2024 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0. + * you may not use this file except in compliance with the License. + */ +const SERVER_URL_REGEXP = /^(https:\/\/)?(localhost|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(:\d+)?(\/.*)?$/i; + +export function isValidServerUrl(value: string): boolean { + return SERVER_URL_REGEXP.test(value); +} diff --git a/webapp/packages/core-utils/src/isValidUrl.ts b/webapp/packages/core-utils/src/isValidUrl.ts index 941873a58c..634916b583 100644 --- a/webapp/packages/core-utils/src/isValidUrl.ts +++ b/webapp/packages/core-utils/src/isValidUrl.ts @@ -17,12 +17,6 @@ // 'i', // ); // fragment locator -const serverUrlPattern = /^(https:\/\/)?(localhost|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(:\d+)?(\/.*)?$/i; - export function isValidUrl(value: string): boolean { return value.startsWith('https://') || value.startsWith('http://'); } - -export function isValidServerUrl(value: string): boolean { - return serverUrlPattern.test(value); -} From 1f537bbb61b5650d2eee904284a93196458f0ccd Mon Sep 17 00:00:00 2001 From: sergeyteleshev Date: Wed, 25 Sep 2024 14:22:44 +0200 Subject: [PATCH 08/17] CB-5578 allow any protocol server url but redirect on https only --- webapp/packages/core-utils/src/getHttpsUrl.ts | 15 +++++++++++++++ webapp/packages/core-utils/src/index.ts | 1 + .../packages/core-utils/src/isValidServerUrl.ts | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 webapp/packages/core-utils/src/getHttpsUrl.ts diff --git a/webapp/packages/core-utils/src/getHttpsUrl.ts b/webapp/packages/core-utils/src/getHttpsUrl.ts new file mode 100644 index 0000000000..b9a009e178 --- /dev/null +++ b/webapp/packages/core-utils/src/getHttpsUrl.ts @@ -0,0 +1,15 @@ +/* + * CloudBeaver - Cloud Database Manager + * Copyright (C) 2020-2024 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0. + * you may not use this file except in compliance with the License. + */ + +export function getHttpsUrl(url: string): string { + if (url.startsWith('http://')) { + return url.replace('http://', 'https://'); + } + + return url; +} diff --git a/webapp/packages/core-utils/src/index.ts b/webapp/packages/core-utils/src/index.ts index 70380e26a1..64e2e55d74 100644 --- a/webapp/packages/core-utils/src/index.ts +++ b/webapp/packages/core-utils/src/index.ts @@ -57,6 +57,7 @@ export * from './throttle.js'; export * from './uuid_.js'; export * from './isValidUrl.js'; export * from './isValidServerUrl.js'; +export * from './getHttpsUrl.js'; export * from './isImageFormat.js'; export * from './getCookies.js'; export * from './getUniqueName.js'; diff --git a/webapp/packages/core-utils/src/isValidServerUrl.ts b/webapp/packages/core-utils/src/isValidServerUrl.ts index 9744b8f4da..8436622fde 100644 --- a/webapp/packages/core-utils/src/isValidServerUrl.ts +++ b/webapp/packages/core-utils/src/isValidServerUrl.ts @@ -5,7 +5,7 @@ * Licensed under the Apache License, Version 2.0. * you may not use this file except in compliance with the License. */ -const SERVER_URL_REGEXP = /^(https:\/\/)?(localhost|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(:\d+)?(\/.*)?$/i; +const SERVER_URL_REGEXP = /^(https?:\/\/)?(localhost|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(:\d+)?(\/.*)?$/i; export function isValidServerUrl(value: string): boolean { return SERVER_URL_REGEXP.test(value); From ec36317448d2bb7454cb6aee512fd2c889c3ffec Mon Sep 17 00:00:00 2001 From: sergeyteleshev Date: Wed, 25 Sep 2024 14:23:08 +0200 Subject: [PATCH 09/17] CB-5578 fix error message in details popup --- .../core-blocks/src/ErrorDetailsDialog/ErrorDetailsDialog.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webapp/packages/core-blocks/src/ErrorDetailsDialog/ErrorDetailsDialog.tsx b/webapp/packages/core-blocks/src/ErrorDetailsDialog/ErrorDetailsDialog.tsx index 45c486a6db..44b561d5a5 100644 --- a/webapp/packages/core-blocks/src/ErrorDetailsDialog/ErrorDetailsDialog.tsx +++ b/webapp/packages/core-blocks/src/ErrorDetailsDialog/ErrorDetailsDialog.tsx @@ -26,11 +26,12 @@ import { ErrorModel, type IErrorInfo } from './ErrorModel.js'; function DisplayErrorInfo({ error }: { error: IErrorInfo }) { const styles = useS(style); + const translate = useTranslate(); return ( <>
- {error.isHtml ?