include backslashes

This commit is contained in:
Caleb Roseland 2023-11-03 14:46:00 -05:00
parent a8fe9794d0
commit 744d5c1120
2 changed files with 28 additions and 1 deletions

View file

@ -155,7 +155,7 @@ export function parseDeepLink(deepLinkUrl: string): DeepLinkWithData {
function isDeepLinkInvalid(decodedUrl: string) {
const url = decodeURIComponent(decodedUrl);
return url.includes('../') || url.includes('/..');
return Boolean((/([/\\]\.\.|\.\.[/\\])/).exec(url)?.length);
}
export function matchDeepLink(url?: string, serverURL?: string, siteURL?: string) {

View file

@ -195,6 +195,24 @@ describe('UrlUtils', () => {
},
expected: {type: DeepLinkType.Invalid},
},
{
name: 'should return null for backslash-invalid deeplink',
input: {
url: DEEPLINK_URL_ROOT + '/ad-1/channels/\\..town-square',
serverURL: SERVER_URL,
siteURL: SITE_URL,
},
expected: {type: DeepLinkType.Invalid},
},
{
name: 'should return null for backslash-invalid-alt deeplink',
input: {
url: DEEPLINK_URL_ROOT + '/ad-1/channels/t..\\town-square',
serverURL: SERVER_URL,
siteURL: SITE_URL,
},
expected: {type: DeepLinkType.Invalid},
},
{
name: 'should return null for double encoded invalid deeplink',
input: {
@ -204,6 +222,15 @@ describe('UrlUtils', () => {
},
expected: {type: DeepLinkType.Invalid},
},
{
name: 'should return null for double encoded backslash-invalid deeplink',
input: {
url: DEEPLINK_URL_ROOT + '/ad-1/channels/%255C%252e.town-square',
serverURL: SERVER_URL,
siteURL: SITE_URL,
},
expected: {type: DeepLinkType.Invalid},
},
{
name: 'should match channel link',
input: {