Skip to content

Commit

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

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



* Udpate test



---------


(cherry picked from commit b1148fb)

Signed-off-by: Derek Ho <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 053e088 commit 89a5121
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 @@ -52,6 +52,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 @@ -58,7 +58,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 89a5121

Please sign in to comment.