Kibana version:
Current master branch
Describe the bug:
Navigation doesn't work correctly for resources with names containing percent sign with other special characters or containing %25 sequence. The issue occurs in plugins:
The issue occurs because history package (react-router dependency) uses decodeURI on the url and only happens when the user reloads a page or navigates from outside of Kibana via a deep link. The issue doesn't happen when navigating inside Kibana with react-router when encodeURI is used on the url.
Explanation of match params decoding in react-router
const policyName = 'test%#';
const url = encodeURI(`/policies/edit/${encodeURIComponent(policyName)}`);
// url is '/policies/edit/test%2525%2523' (double decoding)
reactRouterNavigate(url);
decodeURI is called internally in react-router/history package
- address bar is set to
test%25%23
- match params coming from react-router is set to
test%25%23
encodeURIComponent('test%25%23') is used in components getting match params from react-router to get the correct policyName test%#.
When the user reloads the page, react-router decodes the value coming from the address bar:
decodeURI('test%25%23') results in match params set to test%%23
- calling
encodeURIComponent('test%%23') throws an URIError, so using match params directly results in the wrong policy name test%%23.
The issue might be fixed once react-router is updated to v6 (which uses history v5).
Related history packages issues: 505, 777, 786
Steps to reproduce:
- Create a policy with the name
test%25 or test%# and click 'save' button.
- In the policies table, click on the newly created policy to navigate to the edit page.
- Reload the edit page, the name of the policy will be
test% (not test%25) or test%%23 (not test%#).
- Index Management (index templates tab)
- Create an index template with the name
test%25 or test%#
- After saving, the app will redirect to index templates table with a detail flyout displaying the newly created index template.
- Reload the page, the name of the template will be
test% (not test%25) or test%%23 (not test%#).
Screenshot
Kibana version:
Current master branch
Describe the bug:
Navigation doesn't work correctly for resources with names containing percent sign with other special characters or containing
%25sequence. The issue occurs in plugins:The issue occurs because
historypackage (react-routerdependency) usesdecodeURIon the url and only happens when the user reloads a page or navigates from outside of Kibana via a deep link. The issue doesn't happen when navigating inside Kibana withreact-routerwhenencodeURIis used on the url.Explanation of match params decoding in react-router
decodeURIis called internally inreact-router/historypackagetest%25%23test%25%23encodeURIComponent('test%25%23')is used in components getting match params from react-router to get the correct policyNametest%#.When the user reloads the page, react-router decodes the value coming from the address bar:
decodeURI('test%25%23')results in match params set totest%%23encodeURIComponent('test%%23')throws anURIError, so using match params directly results in the wrong policy nametest%%23.The issue might be fixed once
react-routeris updated to v6 (which useshistoryv5).Related history packages issues: 505, 777, 786
Steps to reproduce:
test%25ortest%#and click 'save' button.test%(nottest%25) ortest%%23(nottest%#).test%25ortest%#test%(nottest%25) ortest%%23(nottest%#).Screenshot