Removed some deprecation warnings spotted in pytest output. Harden waitress

This commit is contained in:
Miguel Jacq 2023-05-30 10:46:11 +10:00
parent 61652f0b6d
commit 9a19c47185
No known key found for this signature in database
GPG Key ID: 59B3F0C24135C6A9
3 changed files with 12 additions and 6 deletions

View File

@ -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)

View File

@ -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

View File

@ -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):