mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Security Solution] fix broken encoding for the expandable flyout values (#172603)
## Summary This fixes an issue with url encoding in the flyout. Turns out that `rison` does not produce url safe strings by default.
This commit is contained in:
parent
ff9c299fc9
commit
3390d8c54a
2 changed files with 20 additions and 2 deletions
|
@ -52,7 +52,24 @@ describe('useSyncToUrl', () => {
|
|||
expect(window.history.pushState).toHaveBeenCalledWith(
|
||||
{},
|
||||
'',
|
||||
'#should_be_there?namespace=(test:foo)'
|
||||
'#should_be_there?namespace=(test%3Afoo)'
|
||||
);
|
||||
});
|
||||
|
||||
it('should escape values correctly', () => {
|
||||
window.location.hash = '#should_be_there';
|
||||
|
||||
const { result } = renderHook(() => useUrlState('namespace', 'test'));
|
||||
|
||||
act(() => {
|
||||
result.current[1]('foo#bar');
|
||||
jest.runAllTimers();
|
||||
});
|
||||
|
||||
expect(window.history.pushState).toHaveBeenCalledWith(
|
||||
{},
|
||||
'',
|
||||
'#should_be_there?namespace=(test%3Afoo%23bar)'
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -99,9 +99,10 @@ export const useUrlState = <T = unknown>(urlNamespace: string, key: string) => {
|
|||
if (!Object.prototype.hasOwnProperty.call(cache.namespaces, ns)) {
|
||||
continue;
|
||||
}
|
||||
searchParams[ns] = encode(cache.namespaces[ns]);
|
||||
searchParams[ns] = encodeURIComponent(encode(cache.namespaces[ns]));
|
||||
}
|
||||
|
||||
// NOTE: don't re-encode the entire url params string
|
||||
const newSearch = stringify(searchParams, { encode: false });
|
||||
|
||||
if (window.location.search === newSearch) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue