Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 1.3] Fix a bug where basepath nextUrl is invalid when it should be valid #2098

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading