diff --git a/src/legacy/core_plugins/elasticsearch/lib/create_proxy.js b/src/legacy/core_plugins/elasticsearch/lib/create_proxy.js index a0e7a2599dc1..d1ad422b5c67 100644 --- a/src/legacy/core_plugins/elasticsearch/lib/create_proxy.js +++ b/src/legacy/core_plugins/elasticsearch/lib/create_proxy.js @@ -54,7 +54,7 @@ export function createProxy(server) { handler(req, h) { const { query, payload: body } = req; return callWithRequest(req, 'transport.request', { - path: `/${req.params.index}/_search`, + path: `/${encodeURIComponent(req.params.index)}/_search`, method: 'POST', query, body diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__jest__/__snapshots__/status_message.test.js.snap b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__jest__/__snapshots__/status_message.test.js.snap index 0cdb384b3af2..748eb2d0b968 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__jest__/__snapshots__/status_message.test.js.snap +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/__jest__/__snapshots__/status_message.test.js.snap @@ -2,6 +2,7 @@ exports[`StatusMessage should render with exact matches 1`] = ` @@ -48,6 +49,7 @@ exports[`StatusMessage should render with exact matches 1`] = ` exports[`StatusMessage should render with no partial matches 1`] = ` @@ -83,6 +85,7 @@ exports[`StatusMessage should render with no partial matches 1`] = ` exports[`StatusMessage should render with partial matches 1`] = ` @@ -118,6 +121,7 @@ exports[`StatusMessage should render with partial matches 1`] = ` exports[`StatusMessage should render without a query 1`] = ` @@ -145,6 +149,7 @@ exports[`StatusMessage should render without a query 1`] = ` exports[`StatusMessage should show that no indices exist 1`] = ` @@ -165,6 +170,7 @@ exports[`StatusMessage should show that no indices exist 1`] = ` exports[`StatusMessage should show that system indices exist 1`] = ` diff --git a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.js b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.js index 772d7ec900ec..035d28bb126a 100644 --- a/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.js +++ b/src/legacy/core_plugins/kibana/public/management/sections/index_patterns/create_index_pattern_wizard/components/step_index_pattern/components/status_message/status_message.js @@ -161,7 +161,7 @@ export const StatusMessage = ({ } return ( - + { statusIcon ? : null } {statusMessage} diff --git a/test/functional/apps/management/_index_pattern_create_delete.js b/test/functional/apps/management/_index_pattern_create_delete.js index 002936f060bb..102f38d091b3 100644 --- a/test/functional/apps/management/_index_pattern_create_delete.js +++ b/test/functional/apps/management/_index_pattern_create_delete.js @@ -24,7 +24,8 @@ export default function ({ getService, getPageObjects }) { const browser = getService('browser'); const log = getService('log'); const retry = getService('retry'); - const PageObjects = getPageObjects(['settings', 'common']); + const testSubjects = getService('testSubjects'); + const PageObjects = getPageObjects(['settings', 'common', 'header']); describe('creating and deleting default index', function describeIndexTests() { before(function () { @@ -38,6 +39,28 @@ export default function ({ getService, getPageObjects }) { }); }); + describe('special character handling', () => { + it('should handle special charaters in template input', async () => { + await PageObjects.settings.clickOptionalAddNewButton(); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.settings.setIndexPatternField({ + indexPatternName: '❤️', + expectWildcard: false + }); + await PageObjects.header.waitUntilLoadingHasFinished(); + + await retry.try(async () => { + expect(await testSubjects.getVisibleText('createIndexPatternStatusMessage')) + .to.contain(`The index pattern you've entered doesn't match any indices`); + }); + }); + + after(async () => { + await PageObjects.settings.navigateTo(); + await PageObjects.settings.clickKibanaIndices(); + }); + }); + describe('index pattern creation', function indexPatternCreation() { let indexPatternId; diff --git a/test/functional/page_objects/settings_page.js b/test/functional/page_objects/settings_page.js index c49a133bd3ab..bf76eb0eb199 100644 --- a/test/functional/page_objects/settings_page.js +++ b/test/functional/page_objects/settings_page.js @@ -277,7 +277,7 @@ export function SettingsPageProvider({ getService, getPageObjects }) { await this.clickOptionalAddNewButton(); await PageObjects.header.waitUntilLoadingHasFinished(); await retry.try(async () => { - await this.setIndexPatternField(indexPatternName); + await this.setIndexPatternField({ indexPatternName }); }); await PageObjects.common.sleep(2000); await (await this.getCreateIndexPatternGoToStep2Button()).click(); @@ -317,14 +317,14 @@ export function SettingsPageProvider({ getService, getPageObjects }) { return indexPatternId; } - async setIndexPatternField(indexPatternName = 'logstash-') { + async setIndexPatternField({ indexPatternName = 'logstash-', expectWildcard = true } = {}) { log.debug(`setIndexPatternField(${indexPatternName})`); const field = await this.getIndexPatternField(); await field.clearValue(); await field.type(indexPatternName); const currentName = await field.getAttribute('value'); log.debug(`setIndexPatternField set to ${currentName}`); - expect(currentName).to.eql(`${indexPatternName}*`); + expect(currentName).to.eql(`${indexPatternName}${expectWildcard ? '*' : ''}`); } async getCreateIndexPatternGoToStep2Button() { diff --git a/x-pack/plugins/index_lifecycle_management/server/routes/api/index/register_get_affected_route.js b/x-pack/plugins/index_lifecycle_management/server/routes/api/index/register_get_affected_route.js index ed5b6b09db16..2de097541db2 100644 --- a/x-pack/plugins/index_lifecycle_management/server/routes/api/index/register_get_affected_route.js +++ b/x-pack/plugins/index_lifecycle_management/server/routes/api/index/register_get_affected_route.js @@ -51,7 +51,7 @@ async function getAffectedIndices( } const indexParams = { method: 'GET', - path: `/${indexPatterns.join(',')}`, + path: `/${encodeURIComponent(indexPatterns.join(','))}`, // we allow 404 in case there are no indices ignore: [404] }; diff --git a/x-pack/plugins/index_lifecycle_management/server/routes/api/templates/register_add_policy_route.js b/x-pack/plugins/index_lifecycle_management/server/routes/api/templates/register_add_policy_route.js index ba6d42e72002..d4197b20abb7 100644 --- a/x-pack/plugins/index_lifecycle_management/server/routes/api/templates/register_add_policy_route.js +++ b/x-pack/plugins/index_lifecycle_management/server/routes/api/templates/register_add_policy_route.js @@ -34,7 +34,7 @@ async function updateIndexTemplate(callWithRequest, indexTemplatePatch) { const params = { method: 'PUT', - path: `/_template/${indexTemplatePatch.templateName}`, + path: `/_template/${encodeURIComponent(indexTemplatePatch.templateName)}`, ignore: [ 404 ], body: template, }; @@ -67,4 +67,4 @@ export function registerAddPolicyRoute(server) { pre: [ licensePreRouting ] } }); -} \ No newline at end of file +} diff --git a/x-pack/plugins/index_lifecycle_management/server/routes/api/templates/register_get_route.js b/x-pack/plugins/index_lifecycle_management/server/routes/api/templates/register_get_route.js index ad24160fe798..4b234571208d 100644 --- a/x-pack/plugins/index_lifecycle_management/server/routes/api/templates/register_get_route.js +++ b/x-pack/plugins/index_lifecycle_management/server/routes/api/templates/register_get_route.js @@ -15,7 +15,7 @@ import { licensePreRoutingFactory } from'../../../lib/license_pre_routing_factor async function fetchTemplate(callWithRequest, templateName) { const params = { method: 'GET', - path: `/_template/${templateName}`, + path: `/_template/${encodeURIComponent(templateName)}`, // we allow 404 incase the user shutdown security in-between the check and now ignore: [ 404 ] };