From 0c9ee0e0e00f87b146596444f987d70fec313758 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 30 Nov 2022 20:28:24 -0500 Subject: [PATCH 1/8] Fix plus sign in path bug with downloads & uploads --- app/classes/web/ajax_handler.py | 3 ++- app/classes/web/panel_handler.py | 8 +++++--- app/classes/web/upload_handler.py | 5 ++++- app/frontend/templates/panel/server_files.html | 4 +++- app/frontend/templates/server/bedrock_wizard.html | 6 +++--- app/frontend/templates/server/wizard.html | 6 +++--- 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/app/classes/web/ajax_handler.py b/app/classes/web/ajax_handler.py index fe3fb14f..61e2c40d 100644 --- a/app/classes/web/ajax_handler.py +++ b/app/classes/web/ajax_handler.py @@ -4,6 +4,7 @@ import pathlib import re import logging import time +import urllib.parse import bleach import tornado.web import tornado.escape @@ -507,7 +508,7 @@ class AjaxHandler(BaseHandler): self.redirect("/panel/dashboard") elif page == "unzip_server": - path = self.get_argument("path", None) + path = urllib.parse.unquote(self.get_argument("path", None)) if not path: path = os.path.join( self.controller.project_root, diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index d64774bd..24ab74a7 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -7,6 +7,7 @@ import json import logging import threading import shlex +import urllib.parse import bleach import requests import tornado.web @@ -1386,9 +1387,10 @@ class PanelHandler(BaseHandler): template = "panel/activity_logs.html" elif page == "download_file": - file = Helpers.get_os_understandable_path(self.get_argument("path", "")) - name = self.get_argument("name", "") - + file = Helpers.get_os_understandable_path( + urllib.parse.unquote(self.get_argument("path", "")) + ) + name = urllib.parse.unquote(self.get_argument("name", "")) server_id = self.check_server_id() if server_id is None: return diff --git a/app/classes/web/upload_handler.py b/app/classes/web/upload_handler.py index 2de4fe1f..785d5783 100644 --- a/app/classes/web/upload_handler.py +++ b/app/classes/web/upload_handler.py @@ -1,6 +1,7 @@ import logging import os import time +import urllib.parse import tornado.web import tornado.options import tornado.httpserver @@ -108,7 +109,9 @@ class UploadHandler(BaseHandler): logger.debug("Could not delete file on user server upload") self.helper.ensure_dir_exists(path) - filename = self.request.headers.get("X-FileName", None) + filename = urllib.parse.unquote( + self.request.headers.get("X-FileName", None) + ) if not str(filename).endswith(".zip"): self.helper.websocket_helper.broadcast("close_upload_box", "error") self.finish("error") diff --git a/app/frontend/templates/panel/server_files.html b/app/frontend/templates/panel/server_files.html index ebcf0d3b..af287b43 100644 --- a/app/frontend/templates/panel/server_files.html +++ b/app/frontend/templates/panel/server_files.html @@ -1027,7 +1027,9 @@ function downloadFileE(event) { path = event.target.parentElement.getAttribute('data-path'); name = event.target.parentElement.getAttribute('data-name'); - window.location.href = `/panel/download_file?id=${serverId}&path=${path}&name=${name}`; + encoded_path = encodeURIComponent(path) + encoded_name = encodeURIComponent(name) + window.location.href = `/panel/download_file?id=${serverId}&path=${encoded_path}&name=${encoded_name}`; } function renameItemE(event) { diff --git a/app/frontend/templates/server/bedrock_wizard.html b/app/frontend/templates/server/bedrock_wizard.html index 8b9839e1..a29afcf8 100644 --- a/app/frontend/templates/server/bedrock_wizard.html +++ b/app/frontend/templates/server/bedrock_wizard.html @@ -565,7 +565,7 @@ document.getElementById("upload_input").innerHTML = '
 
' let xmlHttpRequest = new XMLHttpRequest(); let token = getCookie("_xsrf") - let fileName = file.name + let fileName = encodeURIComponent(file.name) let target = '/upload' let mimeType = file.type let size = file.size @@ -610,7 +610,7 @@ $.ajax({ type: "POST", headers: { 'X-XSRFToken': token }, - url: '/ajax/unzip_server?id=-1&file=' + file.name, + url: '/ajax/unzip_server?id=-1&file=' + encodeURIComponent(file.name), }); } else { bootbox.alert("You must input a path before selecting this button"); @@ -663,7 +663,7 @@ $.ajax({ type: "POST", headers: { 'X-XSRFToken': token }, - url: '/ajax/unzip_server?id=-1&path=' + path, + url: '/ajax/unzip_server?id=-1&path=' + encodeURIComponent(path), }); } else { bootbox.alert("You must input a path before selecting this button"); diff --git a/app/frontend/templates/server/wizard.html b/app/frontend/templates/server/wizard.html index 8346ca92..fd8d3773 100644 --- a/app/frontend/templates/server/wizard.html +++ b/app/frontend/templates/server/wizard.html @@ -788,7 +788,7 @@ $.ajax({ type: "POST", headers: { 'X-XSRFToken': token }, - url: '/ajax/unzip_server?id=-1&path=' + path, + url: '/ajax/unzip_server?id=-1&path=' + encodeURIComponent(path), }); } else { bootbox.alert("You must input a path before selecting this button"); @@ -853,7 +853,7 @@ $.ajax({ type: "POST", headers: { 'X-XSRFToken': token }, - url: '/ajax/unzip_server?id=-1&path=' + path, + url: '/ajax/unzip_server?id=-1&path=' + encodeURIComponent(path), }); } else { bootbox.alert("You must input a path before selecting this button"); @@ -875,7 +875,7 @@ $.ajax({ type: "POST", headers: { 'X-XSRFToken': token }, - url: '/ajax/unzip_server?id=-1&file=' + file.name, + url: '/ajax/unzip_server?id=-1&file=' + encodeURIComponent(file.name), }); } else { bootbox.alert("You must input a path before selecting this button"); From 48a6f98cb55a7af33a4dac20caa789221d01e527 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 30 Nov 2022 21:50:55 -0500 Subject: [PATCH 2/8] Fix port not showing on dash while server online --- app/frontend/templates/panel/dashboard.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/frontend/templates/panel/dashboard.html b/app/frontend/templates/panel/dashboard.html index 1fac58cf..171f2b8a 100644 --- a/app/frontend/templates/panel/dashboard.html +++ b/app/frontend/templates/panel/dashboard.html @@ -278,9 +278,10 @@ {% end %} - + +
{% if server['stats']['running'] %} {{ translate('dashboard', 'online', data['lang']) }} @@ -299,6 +300,7 @@ data-players="{{ server['stats']['online']}}" data-max="{{ server['stats']['max'] }}"> {% end %} +
{% for server in data['failed_servers'] %} From 4baaec8752e9b3dd2d1bd28afd4b885db82b9db1 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 2 Dec 2022 13:06:10 -0500 Subject: [PATCH 3/8] Fix colors on public pages. --- app/frontend/templates/public_base.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/frontend/templates/public_base.html b/app/frontend/templates/public_base.html index 5a6d9bdb..33972b79 100644 --- a/app/frontend/templates/public_base.html +++ b/app/frontend/templates/public_base.html @@ -1,5 +1,5 @@ - + @@ -24,7 +24,7 @@ - +
From b133a7bdea86606f4a5a355583fcdf60d89887cd Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 3 Dec 2022 20:48:22 -0500 Subject: [PATCH 4/8] Fix background key not on public pages --- app/classes/web/panel_handler.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index d64774bd..a5c5a416 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -289,6 +289,7 @@ class PanelHandler(BaseHandler): page_data: t.Dict[str, t.Any] = { # todo: make this actually pull and compare version data "update_available": self.helper.update_available, + "background": self.controller.cached_login, "serverTZ": tz, "version_data": self.helper.get_version_string(), "failed_servers": self.controller.servers.failed_servers, From f337d00887f1aad77fb5c06dca4da88bb2339432 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Wed, 7 Dec 2022 13:23:26 +0000 Subject: [PATCH 5/8] Update changelog !503 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93283e60..ed59ff01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ### New features TBD ### Bug fixes -TBD +- Fix port tooltip not showing on dash while server online ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/503)) ### Tweaks TBD ### Lang From 0fca232affc02f80a4d70a244c387ee916911ea4 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Wed, 7 Dec 2022 13:38:39 +0000 Subject: [PATCH 6/8] Update changelog !502 --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed59ff01..a3fb4e00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,8 @@ ### New features TBD ### Bug fixes -- Fix port tooltip not showing on dash while server online ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/503)) +- Fix port tooltip not showing on dash while server online. ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/503)) +- Fix '+' char in path causing any file operation to fail. ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/502)) ### Tweaks TBD ### Lang From 05ab568249eac97fcb12128d94008238b047c454 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Wed, 7 Dec 2022 13:47:41 +0000 Subject: [PATCH 7/8] Update changelog !504 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3fb4e00..c62f970f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ TBD ### Bug fixes - Fix port tooltip not showing on dash while server online. ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/503)) - Fix '+' char in path causing any file operation to fail. ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/502)) +- Fix colours on public pages. ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/504)) ### Tweaks TBD ### Lang From 9a5bafe4893b2f95e8cb1a0226845bf6d8f56117 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Wed, 7 Dec 2022 14:14:55 +0000 Subject: [PATCH 8/8] Update changelog !505 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c62f970f..dae036f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ TBD - Fix port tooltip not showing on dash while server online. ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/503)) - Fix '+' char in path causing any file operation to fail. ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/502)) - Fix colours on public pages. ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/504)) +- Fix bug where public background was not sent to public pages...like the error page resulting in an error...ironic...I know. ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/505)) ### Tweaks TBD ### Lang