-
Notifications
You must be signed in to change notification settings - Fork 33
Fix multi site #479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix multi site #479
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1101,9 +1101,14 @@ def publish_view(self, request, object_id): | |
self.message_user(request, _("Version published")) | ||
|
||
# Redirect to published? | ||
if conf.ON_PUBLISH_REDIRECT == "published": | ||
if hasattr(version.content, "get_absolute_url"): | ||
requested_redirect = requested_redirect or version.content.get_absolute_url() | ||
if not requested_redirect and conf.ON_PUBLISH_REDIRECT == "published": | ||
if hasattr(version.content, "get_full_url"): | ||
full_url = version.content.get_full_url() | ||
if full_url: | ||
# Can't resolve full_url, redirect directly to it | ||
Comment on lines
+1107
to
+1108
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚨 issue (security): Redirecting directly to 'full_url' may bypass internal URL resolution. Validating 'full_url' before redirecting can help prevent open redirect vulnerabilities. Ensure the URL is within the expected domain or document why this approach is secure. |
||
return redirect(full_url) | ||
elif hasattr(version.content, "get_absolute_url"): | ||
requested_redirect = version.content.get_absolute_url() | ||
|
||
return self._internal_redirect(requested_redirect, redirect_url) | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -258,7 +258,9 @@ def _add_view_published_button(self): | |||||||||||||||||||
if not published_version: | ||||||||||||||||||||
return | ||||||||||||||||||||
|
||||||||||||||||||||
url = published_version.get_absolute_url() if hasattr(published_version, "get_absolute_url") else None | ||||||||||||||||||||
url = published_version.get_full_url() if hasattr(published_version, "get_full_url") else None | ||||||||||||||||||||
if not url and hasattr(published_version, "get_absolute_url"): | ||||||||||||||||||||
url = published_version.get_absolute_url() | ||||||||||||||||||||
Comment on lines
+261
to
+263
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: The fallback logic for URL resolution could be simplified. If 'get_full_url' exists but returns a falsy value, the code falls back to 'get_absolute_url'. Confirm this is intentional, as it could hide problems with 'get_full_url' implementations.
Suggested change
|
||||||||||||||||||||
if url and (self.toolbar.edit_mode_active or self.toolbar.preview_mode_active): | ||||||||||||||||||||
item = ButtonList(side=self.toolbar.RIGHT) | ||||||||||||||||||||
item.add_button( | ||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): Use named expression to simplify assignment and conditional (
use-named-expression
)