Skip to content

Commit 0f240e6

Browse files
committed
removed security control
1 parent 40437e9 commit 0f240e6

1 file changed

Lines changed: 3 additions & 15 deletions

File tree

src/app/bitstream-page/legacy-bitstream-url-redirect.guard.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,9 @@ export const legacyBitstreamURLRedirectGuard: CanActivateFn = (
4848
getFirstCompletedRemoteData(),
4949
map((rd: RemoteData<Bitstream>) => {
5050
if (rd.hasSucceeded && !rd.hasNoContent) {
51-
let nameSpace = (appConfig.ui.nameSpace || '').replace(/^\/+|\/+$/g, '');
52-
// Neutralize any absolute-like values (http:, https:, //, protocol-relative URLs, or invalid characters)
53-
const allowedNamespaceRegex = /^[a-zA-Z0-9_-]+$/;
54-
// Check for absolute URLs, protocol-relative URLs, or invalid characters
55-
if (
56-
nameSpace.startsWith('http:') ||
57-
nameSpace.startsWith('https:') ||
58-
nameSpace.startsWith('//') ||
59-
nameSpace.match(/^\/[^\/]/) || // protocol-relative URL: single slash followed by non-slash
60-
!allowedNamespaceRegex.test(nameSpace)
61-
) {
62-
nameSpace = '';
63-
}
64-
const redirectPath = nameSpace ? `/${nameSpace}/bitstreams/${rd.payload.uuid}/download` : `/bitstreams/${rd.payload.uuid}/download`;
65-
const redirectUrl = new URL(redirectPath, serverHardRedirectService.getCurrentOrigin()).href;
51+
const nameSpace = appConfig.ui.nameSpace?.replace(/\/$/, '') || '';
52+
const redirectUrl = new URL(nameSpace + `/bitstreams/${rd.payload.uuid}/download`, serverHardRedirectService.getCurrentOrigin()).href;
53+
console.log('Legacy bitstream URL redirecting to:', redirectUrl);
6654
serverHardRedirectService.redirect(redirectUrl, 301);
6755
return false;
6856
} else {

0 commit comments

Comments
 (0)