From 5d0918a6cb1ceaf468b59da90e2b3ed884182f3a Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 20 Jul 2023 12:21:09 +0100 Subject: [PATCH 1/4] Prevent invalid characters in column names when importing tables --- packages/bbui/src/Icon/Icon.svelte | 12 ++--- .../DataTable/modals/CreateEditColumn.svelte | 3 +- .../TableNavigator/TableDataImport.svelte | 46 ++++++++++--------- packages/server/src/utilities/schema.ts | 8 ++++ packages/shared-core/src/constants.ts | 1 + 5 files changed, 38 insertions(+), 32 deletions(-) diff --git a/packages/bbui/src/Icon/Icon.svelte b/packages/bbui/src/Icon/Icon.svelte index 452a8c74a1..a2cf8a1b3a 100644 --- a/packages/bbui/src/Icon/Icon.svelte +++ b/packages/bbui/src/Icon/Icon.svelte @@ -47,7 +47,7 @@ {#if tooltip && showTooltip}
- +
{/if} @@ -80,15 +80,9 @@ position: absolute; pointer-events: none; left: 50%; - top: calc(100% + 4px); - width: 100vw; - max-width: 150px; + bottom: calc(100% + 4px); transform: translateX(-50%); text-align: center; - } - - .spectrum-Icon--sizeXS { - width: 10px; - height: 10px; + z-index: 1; } diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte index 6ffd7f8bb3..f319f09b16 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte @@ -33,6 +33,7 @@ import { getBindings } from "components/backend/DataTable/formula" import { getContext } from "svelte" import JSONSchemaModal from "./JSONSchemaModal.svelte" + import { ValidColumnNameRegex } from "@budibase/shared-core" const AUTO_TYPE = "auto" const FORMULA_TYPE = FIELDS.FORMULA.type @@ -379,7 +380,7 @@ const newError = {} if (!external && fieldInfo.name?.startsWith("_")) { newError.name = `Column name cannot start with an underscore.` - } else if (fieldInfo.name && !fieldInfo.name.match(/^[_a-zA-Z0-9\s]*$/g)) { + } else if (fieldInfo.name && !fieldInfo.name.match(ValidColumnNameRegex)) { newError.name = `Illegal character; must be alpha-numeric.` } else if (PROHIBITED_COLUMN_NAMES.some(name => fieldInfo.name === name)) { newError.name = `${PROHIBITED_COLUMN_NAMES.join( diff --git a/packages/builder/src/components/backend/TableNavigator/TableDataImport.svelte b/packages/builder/src/components/backend/TableNavigator/TableDataImport.svelte index f34a3e9c98..1191f92b31 100644 --- a/packages/builder/src/components/backend/TableNavigator/TableDataImport.svelte +++ b/packages/builder/src/components/backend/TableNavigator/TableDataImport.svelte @@ -1,5 +1,5 @@
@@ -127,10 +129,8 @@ on:change={handleFile} />
{/each}