mirror of
https://github.com/onionshare/onionshare.git
synced 2025-04-29 14:19:30 -04:00
Use importlib.metadata.version('flask') to detect Flask version
This commit is contained in:
parent
303c83604c
commit
ea34d32406
1 changed files with 2 additions and 1 deletions
|
@ -17,6 +17,7 @@ GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
"""
|
"""
|
||||||
|
import importlib
|
||||||
import logging
|
import logging
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import os
|
import os
|
||||||
|
@ -34,7 +35,6 @@ from flask import (
|
||||||
abort,
|
abort,
|
||||||
make_response,
|
make_response,
|
||||||
send_file,
|
send_file,
|
||||||
__version__ as flask_version,
|
|
||||||
)
|
)
|
||||||
from flask_compress import Compress
|
from flask_compress import Compress
|
||||||
from flask_socketio import SocketIO
|
from flask_socketio import SocketIO
|
||||||
|
@ -138,6 +138,7 @@ class Web:
|
||||||
# by default. To prevent content injection through template variables in
|
# by default. To prevent content injection through template variables in
|
||||||
# earlier versions of Flask, we force autoescaping in the Jinja2 template
|
# earlier versions of Flask, we force autoescaping in the Jinja2 template
|
||||||
# engine if we detect a Flask version with insecure default behavior.
|
# engine if we detect a Flask version with insecure default behavior.
|
||||||
|
flask_version = importlib.metadata.version("flask")
|
||||||
if Version(flask_version) < Version("0.11"):
|
if Version(flask_version) < Version("0.11"):
|
||||||
# Monkey-patch in the fix from https://github.com/pallets/flask/commit/99c99c4c16b1327288fd76c44bc8635a1de452bc
|
# Monkey-patch in the fix from https://github.com/pallets/flask/commit/99c99c4c16b1327288fd76c44bc8635a1de452bc
|
||||||
Flask.select_jinja_autoescape = self._safe_select_jinja_autoescape
|
Flask.select_jinja_autoescape = self._safe_select_jinja_autoescape
|
||||||
|
|
Loading…
Add table
Reference in a new issue