Skip to content

Commit

Permalink
Fix a bug where basepath nextUrl is invalid when it should be valid (#…
Browse files Browse the repository at this point in the history
…2096)

* Fix a bug where basepath nextUrl is invalid when it should be valid

Signed-off-by: Derek Ho <[email protected]>

* Udpate test

Signed-off-by: Derek Ho <[email protected]>

---------

Signed-off-by: Derek Ho <[email protected]>
(cherry picked from commit b1148fb)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Aug 21, 2024
1 parent e78ba0d commit bbe2bbd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions server/utils/next_url.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ describe('test validateNextUrl', () => {
expect(validateNextUrl(url, '')).toEqual(undefined);
});

test('allow basePath', () => {
const url = '/osd';
expect(validateNextUrl(url, '/osd')).toEqual(undefined);
});

test('allow dashboard url', () => {
const url =
'/_plugin/opensearch-dashboards/app/opensearch-dashboards#dashbard/dashboard-id?_g=(param=a&p=b)';
Expand Down
2 changes: 1 addition & 1 deletion server/utils/next_url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function validateNextUrl(
}
const pathMinusBase = path.replace(bp, '');
if (
!pathMinusBase.startsWith('/') ||
(pathMinusBase && !pathMinusBase.startsWith('/')) ||
(pathMinusBase.length >= 2 && !/^\/[a-zA-Z_][\/a-zA-Z0-9-_]+$/.test(pathMinusBase))
) {
return INVALID_NEXT_URL_PARAMETER_MESSAGE;
Expand Down

0 comments on commit bbe2bbd

Please sign in to comment.