Skip to content

Commit

Permalink
Merge pull request #19 from ThaaoBlues/main
Browse files Browse the repository at this point in the history
1.6.1
  • Loading branch information
ThaaoBlues authored Jun 21, 2022
2 parents 0663e1b + 864d4fb commit ef94d74
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
18 changes: 9 additions & 9 deletions copypasta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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("/")

Expand Down Expand Up @@ -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)
Expand Down
20 changes: 18 additions & 2 deletions launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -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'])
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.6
1.6.1

0 comments on commit ef94d74

Please sign in to comment.