Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.16] [TSVB] fix incomplete string escaping or encoding (#196248) #196666

Merged
merged 2 commits into from
Oct 18, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const convertToCumulativeSumColumns = (
// lens supports cumulative sum for count and sum as quick function
// and everything else as formula
if (subFunctionMetric.type !== 'count' && pipelineAgg.name !== 'sum') {
const metaValue = Number(meta?.replace(']', ''));
const metaValue = Number(meta?.replace(/\]/g, ''));
formula = getPipelineSeriesFormula(metric, metrics, subFunctionMetric, {
metaValue,
reducedTimeRange,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const convertFormulaScriptForPercentileAggs = (
) => {
variables.forEach((variable) => {
const [_, meta] = variable?.field?.split('[') ?? [];
const metaValue = Number(meta?.replace(']', ''));
const metaValue = Number(meta?.replace(/\]/g, ''));
if (!metaValue) {
return;
}
Expand Down Expand Up @@ -163,7 +163,7 @@ export const convertOtherAggsToFormulaColumn = (
const metric = metrics[metrics.length - 1];
const [fieldId, meta] = metric?.field?.split('[') ?? [];
const subFunctionMetric = metrics.find(({ id }) => id === fieldId);
const metaValue = meta ? Number(meta?.replace(']', '')) : undefined;
const metaValue = meta ? Number(meta?.replace(/\]/g, '')) : undefined;

if (!subFunctionMetric) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ const convertMovingAvgOrDerivativeToColumns = (
if (!pipelineAgg) {
return null;
}
const metaValue = Number(meta?.replace(']', ''));
const metaValue = Number(meta?.replace(/\]/g, ''));
const subMetricField = subFunctionMetric.field;
const [nestedFieldId, _] = subMetricField?.split('[') ?? [];
// support nested aggs with formula
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { addAdditionalArgs } from '.';
import { AdditionalArgs } from '../../types';

const escapeQuotes = (str: string) => {
return str?.replace(/'/g, "\\'");
return str?.replace(/\\/g, '\\\\').replace(/'/g, "\\'");
};

const constructFilterRationFormula = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const getFormulaEquivalent = (
}

return getPipelineSeriesFormula(currentMetric, metrics, subFunctionMetric, {
metaValue: nestedMetaValue ? Number(nestedMetaValue?.replace(']', '')) : undefined,
metaValue: nestedMetaValue ? Number(nestedMetaValue?.replace(/\]/g, '')) : undefined,
reducedTimeRange,
timeShift,
});
Expand Down