Skip to content

Commit e5dfe4a

Browse files
committed
Prevent textContent from leaking into widget query params
1 parent 5a91d86 commit e5dfe4a

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

static/app/views/dashboards/widgetBuilder/utils/convertBuilderStateToStateQueryParams.spec.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ describe('convertBuilderStateToStateQueryParams', () => {
5656
expect(queryParams.selectedAggregate).toBe(0);
5757
});
5858

59+
it('does not include text content in query params', () => {
60+
const mockState: WidgetBuilderState = {
61+
textContent: 'This should not be in URL params',
62+
description: 'Description',
63+
};
64+
65+
const queryParams = convertBuilderStateToStateQueryParams(mockState);
66+
67+
expect(queryParams).not.toHaveProperty('textContent');
68+
expect(queryParams.description).toBe('Description');
69+
});
70+
5971
it('applies the thresholds to the query params', () => {
6072
const mockState: WidgetBuilderState = {
6173
query: ['transaction.duration:>100'],

static/app/views/dashboards/widgetBuilder/utils/convertBuilderStateToStateQueryParams.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@ import {
1111
export function convertBuilderStateToStateQueryParams(
1212
state: WidgetBuilderState
1313
): WidgetBuilderStateQueryParams {
14-
const {fields, yAxis, sort, thresholds, traceMetric, ...rest} = state;
14+
const {
15+
fields,
16+
yAxis,
17+
sort,
18+
thresholds,
19+
traceMetric,
20+
textContent: _textContent,
21+
...rest
22+
} = state;
1523
return {
1624
...rest,
1725
field: serializeFields(fields ?? []),

0 commit comments

Comments
 (0)