Skip to content
Merged

Bugfix #1685

Show file tree
Hide file tree
Changes from 2 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
10 changes: 8 additions & 2 deletions cms/server/admin/handlers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import json
import logging
from urllib.parse import urlsplit

from cms import ServiceCoord, get_service_shards, get_service_address
from cms.db import Admin, Contest, Question
Expand All @@ -48,8 +49,13 @@ def post(self):
next_page: str = self.get_argument("next", None)
Comment thread
pxsit marked this conversation as resolved.
if next_page is not None:
error_args["next"] = next_page
if next_page != "/":
next_page = self.url(*next_page.strip("/").split("/"))
split = urlsplit(next_page)
if split.scheme or split.netloc or not split.path.startswith("/"):
next_page = self.url()
elif split.path != "/":
next_page = self.url(*split.path.strip("/").split("/"))
if split.query:
next_page += "?" + split.query
else:
next_page = self.url()
Comment thread
pxsit marked this conversation as resolved.
Outdated
else:
Expand Down
10 changes: 8 additions & 2 deletions cms/server/contest/handlers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import logging
import os.path
import re
from urllib.parse import urlsplit

import collections

Expand Down Expand Up @@ -217,8 +218,13 @@ def post(self):
next_page: str | None = self.get_argument("next", None)
if next_page is not None:
error_args["next"] = next_page
if next_page != "/":
next_page = self.url(*next_page.strip("/").split("/"))
split = urlsplit(next_page)
if split.scheme or split.netloc or not split.path.startswith("/"):
next_page = self.contest_url()
elif split.path != "/":
next_page = self.url(*split.path.strip("/").split("/"))
if split.query:
next_page += "?" + split.query
Comment thread
pxsit marked this conversation as resolved.
Outdated
else:
next_page = self.url()
else:
Expand Down
Loading