Skip to content

Commit

Permalink
Upgrade the OAuth module to the latest (#1802)
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch authored Apr 13, 2023
1 parent 0f90200 commit af58002
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"dependencies": {
"@slack/logger": "^3.0.0",
"@slack/oauth": "^2.6.0",
"@slack/oauth": "^2.6.1",
"@slack/socket-mode": "^1.3.0",
"@slack/types": "^2.7.0",
"@slack/web-api": "^6.7.1",
Expand Down
13 changes: 12 additions & 1 deletion src/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ export default class App<AppCustomContext extends StringIndexed = StringIndexed>
failure: (error, _installOptions, _req, res) => {
this.logger.debug(error);
res.writeHead(500, { 'Content-Type': 'text/html' });
res.end(`<html><body><h1>OAuth failed!</h1><div>${error}</div></body></html>`);
res.end(`<html><body><h1>OAuth failed!</h1><div>${escapeHtml(error.code)}</div></body></html>`);
},
};
}
Expand Down Expand Up @@ -1563,6 +1563,17 @@ function isEventTypeToSkipAuthorize(eventType: string) {
return eventTypesToSkipAuthorize.includes(eventType);
}

function escapeHtml(input: string | undefined | null): string {
if (input) {
return input.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#x27;');
}
return '';
}

// ----------------------------
// Instrumentation
// Don't change the position of the following code
Expand Down

0 comments on commit af58002

Please sign in to comment.