Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/components/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/components/package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down Expand Up @@ -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",
Expand Down
5 changes: 2 additions & 3 deletions packages/components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -1270,7 +1270,6 @@ export {
EditorMode,
EditorModel,
EMPTY_NS_SEQUENCE_WARNING,
encodeFormDataQuote,
encodePart,
ensureAllFieldsInAllRows,
EntityCreationType,
Expand Down Expand Up @@ -1540,7 +1539,6 @@ export {
MAX_EDITABLE_GRID_ROWS,
MAX_SELECTION_ACTION_ROWS,
MEASUREMENT_UNITS,
UNITS_KIND,
MemberType,
MenuDivider,
MenuHeader,
Expand Down Expand Up @@ -1727,6 +1725,7 @@ export {
UnidentifiedPill,
UNIQUE_ID_FIND_FIELD,
UnitModel,
UNITS_KIND,
updateCellKeySampleIdMap,
updateCellValuesForSampleIds,
updateColumnLookup,
Expand Down
8 changes: 3 additions & 5 deletions packages/components/src/internal/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -255,10 +254,10 @@ export function exportRows(type: EXPORT_TYPES, exportParams: Record<string, any>
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);
}
});

Expand All @@ -285,7 +284,6 @@ export function exportRows(type: EXPORT_TYPES, exportParams: Record<string, any>
throw new Error('Unknown export type: ' + type);
}

form.append('formDataEncoded', 'true');
Ajax.request({
url: ActionURL.buildURL(controller, action, containerPath),
method: 'POST',
Expand Down
8 changes: 3 additions & 5 deletions packages/components/src/internal/components/user/actions.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -58,7 +56,7 @@ export function getUserDetailsRowData(user: User, data: OrderedMap<string, any>,
}

if (value !== undefined) {
formData.append(key, value);
formData.append(Utils.encodeFormName(key), value);
}
});

Expand Down
27 changes: 1 addition & 26 deletions packages/components/src/internal/url/utils.test.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down
8 changes: 0 additions & 8 deletions packages/components/src/internal/url/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading