diff --git a/cli/onionshare_cli/web/send_base_mode.py b/cli/onionshare_cli/web/send_base_mode.py index d690c98d..d8cef496 100644 --- a/cli/onionshare_cli/web/send_base_mode.py +++ b/cli/onionshare_cli/web/send_base_mode.py @@ -25,7 +25,7 @@ import mimetypes import gzip from flask import Response, request from unidecode import unidecode -from werkzeug.urls import url_quote +from urllib.parse import quote class SendBaseModeWeb: @@ -284,7 +284,7 @@ class SendBaseModeWeb: r.headers.set("Content-Length", filesize) filename_dict = { "filename": unidecode(basename), - "filename*": "UTF-8''%s" % url_quote(basename), + "filename*": "UTF-8''%s" % quote(basename), } r.headers.set("Content-Disposition", "inline", **filename_dict) (content_type, _) = mimetypes.guess_type(basename, strict=False) diff --git a/cli/onionshare_cli/web/share_mode.py b/cli/onionshare_cli/web/share_mode.py index a5fb79f0..6af4ae0b 100644 --- a/cli/onionshare_cli/web/share_mode.py +++ b/cli/onionshare_cli/web/share_mode.py @@ -29,7 +29,7 @@ from datetime import datetime, timezone from flask import Response, request, render_template, make_response, abort from unidecode import unidecode from werkzeug.http import parse_date, http_date -from werkzeug.urls import url_quote +from urllib.parse import quote from .send_base_mode import SendBaseModeWeb @@ -231,7 +231,7 @@ class ShareModeWeb(SendBaseModeWeb): r.headers.set("Content-Length", range_[1] - range_[0] + 1) filename_dict = { "filename": unidecode(basename), - "filename*": "UTF-8''%s" % url_quote(basename), + "filename*": "UTF-8''%s" % quote(basename), } r.headers.set("Content-Disposition", "attachment", **filename_dict) # guess content type diff --git a/cli/onionshare_cli/web/web.py b/cli/onionshare_cli/web/web.py index a3f067c1..8dcee656 100644 --- a/cli/onionshare_cli/web/web.py +++ b/cli/onionshare_cli/web/web.py @@ -23,7 +23,7 @@ import os import queue import requests import shutil -from distutils.version import LooseVersion as Version +from packaging.version import Version from waitress.server import create_server import flask @@ -349,7 +349,13 @@ class Web: if self.mode == "chat": self.socketio.run(self.app, host=host, port=port) else: - self.waitress = create_server(self.app, host=host, port=port) + self.waitress = create_server( + self.app, + host=host, + port=port, + clear_untrusted_proxy_headers=True, + ident="OnionShare", + ) self.waitress.run() def stop(self, port):