From fdc6dfe6ca3c5edbbfabf394725d195faaf95028 Mon Sep 17 00:00:00 2001 From: Luke Walker <49527534+lkwr@users.noreply.github.com> Date: Sat, 7 Jan 2023 01:45:16 +0100 Subject: [PATCH 1/3] Improved absolute redirect url detection in actions/loaders --- packages/router/router.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/router/router.ts b/packages/router/router.ts index bf8b979da9..81f215ff7e 100644 --- a/packages/router/router.ts +++ b/packages/router/router.ts @@ -2683,8 +2683,7 @@ async function callLoaderOrAction( "Redirects returned/thrown from loaders/actions must have a Location header" ); - let isAbsolute = - /^[a-z+]+:\/\//i.test(location) || location.startsWith("//"); + let isAbsolute = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(location); // Support relative routing in internal redirects if (!isAbsolute) { From de0c1f501c1677c98f98a0d48d98894468aa9241 Mon Sep 17 00:00:00 2001 From: Luke Walker <49527534+lkwr@users.noreply.github.com> Date: Sat, 7 Jan 2023 02:02:46 +0100 Subject: [PATCH 2/3] Signed CLA --- contributors.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/contributors.yml b/contributors.yml index 0b39965f86..42d874c525 100644 --- a/contributors.yml +++ b/contributors.yml @@ -89,6 +89,7 @@ - latin-1 - lequangdongg - liuhanqu +- lkwr - lopezac - lordofthecactus - loun4 From 742d2b88be9e1a008fd0d95171b3941730916003 Mon Sep 17 00:00:00 2001 From: Luke Walker <49527534+lkwr@users.noreply.github.com> Date: Mon, 9 Jan 2023 19:42:30 +0100 Subject: [PATCH 3/3] add additional redirect urls to router test --- packages/router/__tests__/router-test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/router/__tests__/router-test.ts b/packages/router/__tests__/router-test.ts index fa18d8c0b7..a91a441260 100644 --- a/packages/router/__tests__/router-test.ts +++ b/packages/router/__tests__/router-test.ts @@ -10673,6 +10673,8 @@ describe("a router", () => { "https://remix.run/blog", "//remix.run/blog", "app://whatever", + "mailto:hello@remix.run", + "web+remix:whatever", ]; for (let url of urls) {