Skip to content

Commit 4807e18

Browse files
barbaralocsiAnWeber
authored andcommitted
fix: state parameter validation
1 parent 7355702 commit 4807e18

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/plugins/oauth2/flow/openIdHttpServer.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,10 @@ function initServer(port: number, callbackPath: string) {
144144
}
145145

146146
function parseQueryParams(url: string) {
147-
return url
148-
.slice(url.indexOf('?') + 1)
149-
.split('&')
150-
.reduce(
151-
(prev, current) => {
152-
const [key, value] = current.split('=');
153-
prev[key] = value;
154-
return prev;
155-
},
156-
{} as Record<string, string>
157-
);
147+
const queryStringParameters = url.slice(url.indexOf('?') + 1);
148+
const urlSearchParams = new URLSearchParams(queryStringParameters);
149+
const result: Record<string, string> = Object.fromEntries(urlSearchParams);
150+
return result;
158151
}
159152

160153
function getMessageHtml(message: string, valid: boolean) {

0 commit comments

Comments
 (0)