From 4e8306271f56886af7af256ee3a8401987f212b7 Mon Sep 17 00:00:00 2001 From: Pete Harverson Date: Wed, 11 Mar 2020 16:24:03 +0000 Subject: [PATCH] [ML] Fixes handling of index pattern with special characters (#59884) Co-authored-by: Elastic Machine --- .../application/services/ml_api_service/index.js | 10 +++++++--- .../public/application/services/ml_api_service/jobs.js | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/x-pack/legacy/plugins/ml/public/application/services/ml_api_service/index.js b/x-pack/legacy/plugins/ml/public/application/services/ml_api_service/index.js index 688abd1383ecb..a413dd316b7e3 100644 --- a/x-pack/legacy/plugins/ml/public/application/services/ml_api_service/index.js +++ b/x-pack/legacy/plugins/ml/public/application/services/ml_api_service/index.js @@ -249,7 +249,7 @@ export const ml = { recognizeIndex(obj) { return http({ - url: `${basePath()}/modules/recognize/${obj.indexPatternTitle}`, + url: `${basePath()}/modules/recognize/${encodeURIComponent(obj.indexPatternTitle)}`, method: 'GET', }); }, @@ -308,7 +308,9 @@ export const ml = { ]); return http({ - url: `${basePath()}/data_visualizer/get_field_stats/${obj.indexPatternTitle}`, + url: `${basePath()}/data_visualizer/get_field_stats/${encodeURIComponent( + obj.indexPatternTitle + )}`, method: 'POST', data, }); @@ -326,7 +328,9 @@ export const ml = { ]); return http({ - url: `${basePath()}/data_visualizer/get_overall_stats/${obj.indexPatternTitle}`, + url: `${basePath()}/data_visualizer/get_overall_stats/${encodeURIComponent( + obj.indexPatternTitle + )}`, method: 'POST', data, }); diff --git a/x-pack/legacy/plugins/ml/public/application/services/ml_api_service/jobs.js b/x-pack/legacy/plugins/ml/public/application/services/ml_api_service/jobs.js index 1ac391c7f84ae..cef2b3d2ffd7f 100644 --- a/x-pack/legacy/plugins/ml/public/application/services/ml_api_service/jobs.js +++ b/x-pack/legacy/plugins/ml/public/application/services/ml_api_service/jobs.js @@ -127,7 +127,9 @@ export const jobs = { newJobCaps(indexPatternTitle, isRollup = false) { const isRollupString = isRollup === true ? `?rollup=true` : ''; return http({ - url: `${basePath()}/jobs/new_job_caps/${indexPatternTitle}${isRollupString}`, + url: `${basePath()}/jobs/new_job_caps/${encodeURIComponent( + indexPatternTitle + )}${isRollupString}`, method: 'GET', }); },