Skip to content

Commit

Permalink
fix(ui): protect window.location xss (#1639)
Browse files Browse the repository at this point in the history
protect window.location xss
  • Loading branch information
simeng-li authored Jul 21, 2022
1 parent 69b1b85 commit 34b465c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/ui/src/hooks/use-social-landing-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const useSocialLandingHandler = () => {
storeCallbackLink(connectorId, nativeCallbackLink);
}

window.location.replace(redirectUri);
window.location.replace(new URL(redirectUri));
},
[search, setToast, t]
);
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/pages/SocialLanding/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe(`SocialLanding Page`, () => {
const replace = jest.fn();
it('Should set session storage and redirect', async () => {
const callbackLink = 'logto:logto.android.com';
const redirectUri = 'www.github.com';
const redirectUri = 'http://www.github.com';

/* eslint-disable @silverhand/fp/no-mutating-methods */
Object.defineProperty(window, 'location', {
Expand All @@ -40,7 +40,7 @@ describe(`SocialLanding Page`, () => {
);

await waitFor(() => {
expect(replace).toBeCalledWith(redirectUri);
expect(replace).toBeCalledWith(new URL(redirectUri));
});

expect(getCallbackLinkFromStorage('github')).toBe(callbackLink);
Expand Down

0 comments on commit 34b465c

Please sign in to comment.