mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 14:04:20 +01:00
Fix issue where page URLs were relative (#1798)
* Fix issue where Page URLs were relative in the navbar * Closes #1797
This commit is contained in:
@@ -4,7 +4,7 @@ import os
|
|||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
from flask import current_app as app
|
from flask import current_app as app
|
||||||
from flask import send_file, send_from_directory
|
from flask import send_file, send_from_directory, url_for
|
||||||
|
|
||||||
from CTFd.utils.config.pages import get_pages
|
from CTFd.utils.config.pages import get_pages
|
||||||
from CTFd.utils.decorators import admins_only as admins_only_wrapper
|
from CTFd.utils.decorators import admins_only as admins_only_wrapper
|
||||||
@@ -145,7 +145,15 @@ def get_user_page_menu_bar():
|
|||||||
|
|
||||||
:return: Returns a list of Menu namedtuples. They have name, and route attributes.
|
:return: Returns a list of Menu namedtuples. They have name, and route attributes.
|
||||||
"""
|
"""
|
||||||
return get_pages() + app.plugin_menu_bar
|
pages = []
|
||||||
|
for p in get_pages() + app.plugin_menu_bar:
|
||||||
|
if p.route.startswith("http"):
|
||||||
|
route = p.route
|
||||||
|
else:
|
||||||
|
route = url_for("views.static_html", route=p.route)
|
||||||
|
print(route)
|
||||||
|
pages.append(Menu(title=p.title, route=route))
|
||||||
|
return pages
|
||||||
|
|
||||||
|
|
||||||
def bypass_csrf_protection(f):
|
def bypass_csrf_protection(f):
|
||||||
|
|||||||
@@ -165,11 +165,11 @@ def test_register_user_page_menu_bar():
|
|||||||
|
|
||||||
with app.test_client() as client:
|
with app.test_client() as client:
|
||||||
r = client.get("/")
|
r = client.get("/")
|
||||||
|
|
||||||
output = r.get_data(as_text=True)
|
output = r.get_data(as_text=True)
|
||||||
assert "/test_user_href" in output
|
assert "/test_user_href" in output
|
||||||
assert "test_user_menu_link" in output
|
assert "test_user_menu_link" in output
|
||||||
|
|
||||||
|
with app.test_request_context():
|
||||||
menu_item = get_user_page_menu_bar()[0]
|
menu_item = get_user_page_menu_bar()[0]
|
||||||
assert menu_item.title == "test_user_menu_link"
|
assert menu_item.title == "test_user_menu_link"
|
||||||
assert menu_item.route == "/test_user_href"
|
assert menu_item.route == "/test_user_href"
|
||||||
|
|||||||
Reference in New Issue
Block a user