diff --git a/copypasta.py b/copypasta.py index a7ccb83..5db1e29 100644 --- a/copypasta.py +++ b/copypasta.py @@ -220,10 +220,10 @@ def process(process_id): # try to secure the image path # if suspicious path, just go home - if (not path.exists(image_path)) or (not image_path.startswith("static/files_hist\\")) or (".." in image_path): + if (not path.exists(image_path)) or (not image_path.startswith("static/files_hist/")) or (".." in image_path): return redirect("/") - return redirect(f"/image_preview?path={image_path}") + return redirect(f"/image_preview?image_id={image_id}") #copy scan from history page if "[COPY_SCAN_FROM_HIST]" in process_id: @@ -276,11 +276,11 @@ def process(process_id): # try to secure the image path # if suspicious path, just go home - if (not path.exists(image_path)) or (not image_path.startswith("static/files_hist\\")) or (".." in image_path): + if (not path.exists(image_path)) or (not image_path.startswith("static/files_hist/")) or (".." in image_path): return redirect("/") return send_file(image_path, - download_filename=secure_filename(image_path.replace("static/files_hist/","")), + download_name=secure_filename(image_path.replace("static/files_hist/","")), as_attachment=True) #empty the scan temporary file @@ -321,7 +321,7 @@ def process(process_id): # try to secure the image path # if suspicious path, just go home - if (not path.exists(image_path)) or (not image_path.startswith("static/files_hist\\")) or (".." in image_path): + if (not path.exists(image_path)) or (not image_path.startswith("static/files_hist/")) or (".." in image_path): return redirect("/") try: @@ -364,12 +364,12 @@ def process(process_id): if process_id == "[OPEN FILES EXPLORER]": - Process(target=startfile,args=(f"{APP_PATH}static/files_hist",)).start() + Process(target=startfile,args=(f"{APP_PATH}/static/files_hist",)).start() return redirect("/") if process_id == "[OPEN FILE]": - Process(target=startfile,args=("{}{}".format(APP_PATH,request.args.get("file_path")),)).start() + Process(target=startfile,args=("{}/{}".format(APP_PATH,request.args.get("file_path")),)).start() return redirect("/") @@ -608,12 +608,12 @@ def upload(): elif file : filename = secure_filename(file.filename) file_type = filename.split(".")[-1] - full_path = path.join(app.config['UPLOAD_FOLDER'],"files_hist", filename) + full_path = "{}{}/{}".format(app.config['UPLOAD_FOLDER'],"files_hist",filename) #rename file if one has already its name i = 0 while(path.exists(full_path)): - full_path = path.join(app.config['UPLOAD_FOLDER'],"files_hist", path.splitext(filename)[0]+str(i)+"."+filename.split(".")[-1]) + full_path = "{}{}/{}".format(app.config['UPLOAD_FOLDER'],"files_hist", path.splitext(filename)[0]+str(i)+"."+filename.split(".")[-1]) i += 1 file.save(full_path) diff --git a/launcher.py b/launcher.py index 7984e8d..ed07359 100644 --- a/launcher.py +++ b/launcher.py @@ -3,7 +3,7 @@ from importlib.util import find_spec from requests import get from subprocess import Popen -from shutil import rmtree +from shutil import move, rmtree from zipfile import ZipFile from os import path, chdir, remove,mkdir,environ import sys @@ -54,11 +54,19 @@ def update_main_executable(version: str) -> None: notify_desktop("CopyPasta Installer","Donwloading CopyPasta components...") + try: + # move static folder to keep history + move(f"{APP_PATH}/copypasta/static",f"{EXE_PATH}/static") + except: + # just that the folder does not exists (installation case) + pass + + #remove copypasta folder berfore downloading new version try: rmtree(APP_PATH) except: - #not really an error if the folder have been deleted or folder already exists + #not really an error if the folder have been deleted pass # create copypasta folder if not exists @@ -82,6 +90,14 @@ def update_main_executable(version: str) -> None: #delete zipped file remove("copypasta.zip") + + + # re-put static folder in copypasta + try: + move(f"{EXE_PATH}/static",f"{APP_PATH}/copypasta/static") + except: + # folder does not exists + pass def is_installed() -> None: diff --git a/test.py b/test.py index 4b269bf..510efd6 100644 --- a/test.py +++ b/test.py @@ -1,6 +1,9 @@ from ast import literal_eval +from os import startfile from requests import get +startfile("C:/") + print(literal_eval(get("https://api.github.com/repos/CopyPastaOfficial/CopyPasta/tags").text)[0]['name']) \ No newline at end of file diff --git a/version b/version index dc39e58..2eda823 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.6 \ No newline at end of file +1.6.1 \ No newline at end of file