Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
stefanw wants to merge 2 commits into django-cms:master
base: master
Choose a base branch
Loading
from stefanw:fix-multi-site
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions djangocms_versioning/admin.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Comment on lines +1106 to +1107
Copy link
Contributor

@sourcery-ai sourcery-ai bot Aug 5, 2025

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)

Suggested change
full_url = version.content.get_full_url()
if full_url:
if full_url := version.content.get_full_url():

sourcery-ai[bot] reacted with thumbs up emoji sourcery-ai[bot] reacted with thumbs down emoji
# Can't resolve full_url, redirect directly to it
Comment on lines +1107 to +1108
Copy link
Contributor

@sourcery-ai sourcery-ai bot Aug 5, 2025

Choose a reason for hiding this comment

The 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.

sourcery-ai[bot] reacted with thumbs up emoji sourcery-ai[bot] reacted with thumbs down emoji
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)

Expand Down
4 changes: 3 additions & 1 deletion djangocms_versioning/cms_toolbars.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

@sourcery-ai sourcery-ai bot Aug 5, 2025

Choose a reason for hiding this comment

The 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
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()
if hasattr(published_version, "get_full_url"):
url = published_version.get_full_url()
elif hasattr(published_version, "get_absolute_url"):
url = published_version.get_absolute_url()
else:
url = None

sourcery-ai[bot] reacted with thumbs up emoji sourcery-ai[bot] reacted with thumbs down emoji
if url and (self.toolbar.edit_mode_active or self.toolbar.preview_mode_active):
item = ButtonList(side=self.toolbar.RIGHT)
item.add_button(
Expand Down
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@



<form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="?language={{ language }}{% if request.GET.parent_page %}&amp;parent_page={{ request.GET.parent_page }}{% endif %}{# parameter `parent_node` only for django CMS 4.1 support #}{% if request.GET.parent_node %}&amp;parent_node={{ request.GET.parent_node }}{% endif %}{%if request.GET.source %}&amp;source={{ request.GET.source }}{% endif %}" method="post" id="{{ opts.model_name }}_form">
<form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="?language={{ language }}{% if request.GET.site %}&amp;site={{ request.GET.site }}{% endif %}{% if request.GET.parent_page %}&amp;parent_page={{ request.GET.parent_page }}{% endif %}{# parameter `parent_node` only for django CMS 4.1 support #}{% if request.GET.parent_node %}&amp;parent_node={{ request.GET.parent_node }}{% endif %}{%if request.GET.source %}&amp;source={{ request.GET.source }}{% endif %}" method="post" id="{{ opts.model_name }}_form">
{% csrf_token %}
{% block form_top %}{% endblock %}

Expand Down
Loading

AltStyle によって変換されたページ (->オリジナル) /