diff --git a/packages/components/package-lock.json b/packages/components/package-lock.json index 8da2849358..d9b07ff57a 100644 --- a/packages/components/package-lock.json +++ b/packages/components/package-lock.json @@ -1,16 +1,16 @@ { "name": "@labkey/components", - "version": "7.25.0", + "version": "7.25.1-fb-encodeFormName.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@labkey/components", - "version": "7.25.0", + "version": "7.25.1-fb-encodeFormName.0", "license": "SEE LICENSE IN LICENSE.txt", "dependencies": { "@hello-pangea/dnd": "18.0.1", - "@labkey/api": "1.49.1", + "@labkey/api": "1.49.2-fb-encodeFormName.0", "@testing-library/dom": "~10.4.1", "@testing-library/jest-dom": "~6.9.1", "@testing-library/react": "~16.3.2", @@ -3748,9 +3748,9 @@ } }, "node_modules/@labkey/api": { - "version": "1.49.1", - "resolved": "https://labkey.jfrog.io/artifactory/api/npm/libs-client/@labkey/api/-/@labkey/api-1.49.1.tgz", - "integrity": "sha512-ClFIyggEDH4PC+HB4tnZpaOfIls4MgJugS4TmE6Y5xmVzBm8L442aF/gJFMqcZQ1MMNTP7swRHbfvSvJN5Cmyw==", + "version": "1.49.2-fb-encodeFormName.0", + "resolved": "https://labkey.jfrog.io/artifactory/api/npm/libs-client/@labkey/api/-/@labkey/api-1.49.2-fb-encodeFormName.0.tgz", + "integrity": "sha512-QEghEbSY+c+GbZc4vF98zyvaWRHgW/R6mt38skV3ZcdysIY1ZONnfCKR696pC+klgGKfus/POGLUDHQ58AOnEA==", "license": "Apache-2.0" }, "node_modules/@labkey/build": { diff --git a/packages/components/package.json b/packages/components/package.json index de75a67788..00e585a95e 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -1,6 +1,6 @@ { "name": "@labkey/components", - "version": "7.25.0", + "version": "7.25.1-fb-encodeFormName.0", "description": "Components, models, actions, and utility functions for LabKey applications and pages", "sideEffects": false, "files": [ @@ -53,7 +53,7 @@ "homepage": "https://github.com/LabKey/labkey-ui-components#readme", "dependencies": { "@hello-pangea/dnd": "18.0.1", - "@labkey/api": "1.49.1", + "@labkey/api": "1.49.2-fb-encodeFormName.0", "@testing-library/dom": "~10.4.1", "@testing-library/jest-dom": "~6.9.1", "@testing-library/react": "~16.3.2", diff --git a/packages/components/src/index.ts b/packages/components/src/index.ts index 0a550f0493..0b5e09369d 100644 --- a/packages/components/src/index.ts +++ b/packages/components/src/index.ts @@ -19,7 +19,7 @@ import { applyURL, AppURL, buildURL, spliceURL } from './internal/url/AppURL'; import { AppLink } from './internal/url/AppLink'; import { useAppNavigate } from './internal/url/useAppNavigate'; import { hasParameter, imageURL, toggleParameter } from './internal/url/ActionURL'; -import { encodeFormDataQuote, getIntegerSearchParam } from './internal/url/utils'; +import { getIntegerSearchParam } from './internal/url/utils'; import { Container } from './internal/components/base/models/Container'; import { hasAllPermissions, hasAnyPermissions, hasPermissions, User } from './internal/components/base/models/User'; import { getTextAlignClassName, GridColumn } from './internal/components/base/models/GridColumn'; @@ -1270,7 +1270,6 @@ export { EditorMode, EditorModel, EMPTY_NS_SEQUENCE_WARNING, - encodeFormDataQuote, encodePart, ensureAllFieldsInAllRows, EntityCreationType, @@ -1540,7 +1539,6 @@ export { MAX_EDITABLE_GRID_ROWS, MAX_SELECTION_ACTION_ROWS, MEASUREMENT_UNITS, - UNITS_KIND, MemberType, MenuDivider, MenuHeader, @@ -1727,6 +1725,7 @@ export { UnidentifiedPill, UNIQUE_ID_FIND_FIELD, UnitModel, + UNITS_KIND, updateCellKeySampleIdMap, updateCellValuesForSampleIds, updateColumnLookup, diff --git a/packages/components/src/internal/actions.ts b/packages/components/src/internal/actions.ts index f5b1f06da3..77a10200dd 100644 --- a/packages/components/src/internal/actions.ts +++ b/packages/components/src/internal/actions.ts @@ -45,7 +45,6 @@ import { ViewInfo } from './ViewInfo'; import { createGridModelId } from './models'; import { SAMPLES_KEY } from './app/constants'; import { SCHEMAS } from './schemas'; -import { encodeFormDataQuote } from './url/utils'; export function selectAll( key: string, @@ -255,10 +254,10 @@ export function exportRows(type: EXPORT_TYPES, exportParams: Record const value = exportParams[key]; // Issue 52925: App export to csv/tsv ignores filter with column containing double quote - if (value instanceof Array) { - value.forEach(arrayValue => form.append(encodeFormDataQuote(key), arrayValue)); + if (Array.isArray(value)) { + value.forEach(arrayValue => form.append(Utils.encodeFormName(key), arrayValue)); } else { - form.append(encodeFormDataQuote(key), value); + form.append(Utils.encodeFormName(key), value); } }); @@ -285,7 +284,6 @@ export function exportRows(type: EXPORT_TYPES, exportParams: Record throw new Error('Unknown export type: ' + type); } - form.append('formDataEncoded', 'true'); Ajax.request({ url: ActionURL.buildURL(controller, action, containerPath), method: 'POST', diff --git a/packages/components/src/internal/components/user/actions.ts b/packages/components/src/internal/components/user/actions.ts index 2a5850ffbc..8e93278fec 100644 --- a/packages/components/src/internal/components/user/actions.ts +++ b/packages/components/src/internal/components/user/actions.ts @@ -1,12 +1,10 @@ import { OrderedMap } from 'immutable'; -import { Ajax, PermissionRoles, PermissionTypes, Utils } from '@labkey/api'; +import { Ajax, Utils } from '@labkey/api'; import { buildURL } from '../../url/AppURL'; -import { hasAllPermissions, hasAnyPermissions, User } from '../base/models/User'; +import { User } from '../base/models/User'; import { caseInsensitive } from '../../util/utils'; -import { APPLICATION_SECURITY_ROLES, SITE_SECURITY_ROLES } from '../administration/constants'; - import { formatDate, parseDate } from '../../util/Date'; import { ChangePasswordModel } from './models'; @@ -58,7 +56,7 @@ export function getUserDetailsRowData(user: User, data: OrderedMap, } if (value !== undefined) { - formData.append(key, value); + formData.append(Utils.encodeFormName(key), value); } }); diff --git a/packages/components/src/internal/url/utils.test.ts b/packages/components/src/internal/url/utils.test.ts index 6be8439677..4f0ca343eb 100644 --- a/packages/components/src/internal/url/utils.test.ts +++ b/packages/components/src/internal/url/utils.test.ts @@ -1,29 +1,4 @@ -import { encodeFormDataQuote, getIntegerSearchParam } from './utils'; - -describe('encodeFormDataQuote', () => { - test('empty', () => { - expect(encodeFormDataQuote(null)).toBeNull(); - expect(encodeFormDataQuote(undefined)).toBeUndefined(); - expect(encodeFormDataQuote('')).toBe(''); - }); - - test('no relevant special character', () => { - expect(encodeFormDataQuote('a')).toBe('a') - expect(encodeFormDataQuote('$')).toBe('$'); - expect(encodeFormDataQuote('%')).toBe('%'); - expect(encodeFormDataQuote('%2522')).toBe('%2522'); - }); - - test('encoded', () => { - expect(encodeFormDataQuote('"')).toBe('%22') - expect(encodeFormDataQuote('""')).toBe('%22%22'); - expect(encodeFormDataQuote('"22')).toBe('%2222'); - expect(encodeFormDataQuote('"a"')).toBe('%22a%22'); - expect(encodeFormDataQuote('a%22')).toBe('a%2522'); - expect(encodeFormDataQuote('"a%22')).toBe('%22a%2522'); - expect(encodeFormDataQuote('"a%222')).toBe('%22a%25222'); - }); -}); +import { getIntegerSearchParam } from './utils'; describe('getInterSearchParam', () => { test('no param', () => { diff --git a/packages/components/src/internal/url/utils.ts b/packages/components/src/internal/url/utils.ts index c09453ec17..4e78bf2d01 100644 --- a/packages/components/src/internal/url/utils.ts +++ b/packages/components/src/internal/url/utils.ts @@ -6,14 +6,6 @@ export function encodeListResolverPath(containerPath: string): string { return ['$CPS', containerPath?.toLowerCase(), '$CPE'].join(''); } -// Issue 52925, 52119 -export function encodeFormDataQuote(key: string): string { - if (!key) - return key; - // need to replace %22, before replacing " to %22 - return key?.replaceAll('%22', '%2522').replaceAll('"', '%22'); -} - export function getIntegerSearchParam(searchParams: URLSearchParams, paramName: string): number { const value = parseInt(searchParams.get(paramName), 10); return isNaN(value) ? undefined : value;