github-advanced-security[bot] commented on code in PR #31692:
URL: https://github.com/apache/superset/pull/31692#discussion_r1978485467
##########
superset/initialization/__init__.py:
##########
@@ -701,3 +703,34 @@
@expose("/")
def index(self) -> FlaskResponse:
return redirect("/superset/welcome/")
+
+ @staticmethod
+ def is_safe_url(target: str) -> bool:
+ """
+ Is target is a safe URL to redirect to?
+ """
+ ref_url = urlparse(target)
+ host_url = urlparse(request.host_url)
+ return ref_url.scheme in ("http", "https") and ref_url.netloc ==
host_url.netloc
+
+ @expose("/lang/<string:locale>")
+ @safe
+ def patch_flask_locale(self, locale: str) -> FlaskResponse:
+ """
+ Change user's locale and redirect back to the previous page.
+
+ Overrides FAB's babel.views.LocaleView so we can use the request
+ Referrer as the redirect target, in case our previous page was actually
+ served by the frontend (and thus not added to the session's
page_history
+ stack).
+ """
+ if locale not in self.appbuilder.bm.languages:
Review Comment:
## URL redirection from remote source
Untrusted URL redirection depends on a [user-provided value](1).
[Show more
details](https://github.com/apache/superset/security/code-scanning/1999)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]