1+ import html
12from logging import Logger
23from typing import Optional
34from typing import Union
@@ -32,7 +33,7 @@ def _build_callback_success_response( # type: ignore
3233 debug_message = f"Handling an OAuth callback success (request: { request .query } )"
3334 self ._logger .debug (debug_message )
3435
35- html = self ._redirect_uri_page_renderer .render_success_page (
36+ page_content = self ._redirect_uri_page_renderer .render_success_page (
3637 app_id = installation .app_id ,
3738 team_id = installation .team_id ,
3839 is_enterprise_install = installation .is_enterprise_install ,
@@ -44,7 +45,7 @@ def _build_callback_success_response( # type: ignore
4445 "Content-Type" : "text/html; charset=utf-8" ,
4546 "Set-Cookie" : self ._state_utils .build_set_cookie_for_deletion (),
4647 },
47- body = html ,
48+ body = page_content ,
4849 )
4950
5051 def _build_callback_failure_response ( # type: ignore
@@ -60,14 +61,13 @@ def _build_callback_failure_response( # type: ignore
6061 # Adding a bit more details to the error code to help installers understand what's happening.
6162 # This modification in the HTML page works only when developers use this built-in failure handler.
6263 detailed_error = build_detailed_error (reason )
63- html = self ._redirect_uri_page_renderer .render_failure_page (detailed_error )
6464 return BoltResponse (
6565 status = status ,
6666 headers = {
6767 "Content-Type" : "text/html; charset=utf-8" ,
6868 "Set-Cookie" : self ._state_utils .build_set_cookie_for_deletion (),
6969 },
70- body = html ,
70+ body = self . _redirect_uri_page_renderer . render_failure_page ( detailed_error ) ,
7171 )
7272
7373
@@ -85,7 +85,7 @@ def _build_default_install_page_html(url: str) -> str:
8585</head>
8686<body>
8787<h2>Slack App Installation</h2>
88- <p><a href="{ url } "><img alt=""Add to Slack"" height="40" width="139" src="https://platform.slack-edge.com/img/add_to_slack.png" srcset="https://platform.slack-edge.com/img/add_to_slack.png 1x, https://platform.slack-edge.com/img/[email protected] 2x" /></a></p> 88+ <p><a href="{ html . escape ( url ) } "><img alt=""Add to Slack"" height="40" width="139" src="https://platform.slack-edge.com/img/add_to_slack.png" srcset="https://platform.slack-edge.com/img/add_to_slack.png 1x, https://platform.slack-edge.com/img/[email protected] 2x" /></a></p> 8989</body>
9090</html>
9191""" # noqa: E501
@@ -142,4 +142,4 @@ def build_detailed_error(reason: str) -> str:
142142 elif reason == "storage_error" :
143143 return f"{ reason } : The app's server encountered an issue. Contact the app developer."
144144 else :
145- return f"{ reason } : This error code is returned from Slack. Refer to the documents for details."
145+ return f"{ html . escape ( reason ) } : This error code is returned from Slack. Refer to the documents for details."
0 commit comments