include backslashes
This commit is contained in:
parent
a8fe9794d0
commit
744d5c1120
2 changed files with 28 additions and 1 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue