[httpupload] Dont allow insecure transport
This commit is contained in:
@@ -19,6 +19,7 @@ import threading
|
|||||||
import ssl
|
import ssl
|
||||||
import urllib
|
import urllib
|
||||||
from urllib.request import Request, urlopen
|
from urllib.request import Request, urlopen
|
||||||
|
from urllib.parse import urlparse
|
||||||
import io
|
import io
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import logging
|
import logging
|
||||||
@@ -269,6 +270,16 @@ class Base(object):
|
|||||||
transient_for=file.control.parent_win.window)
|
transient_for=file.control.parent_win.window)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
if (urlparse(file.put).scheme != 'https' or
|
||||||
|
urlparse(file.get).scheme != 'https'):
|
||||||
|
raise UnsecureTransportError
|
||||||
|
except UnsecureTransportError as error:
|
||||||
|
file.progress.close_dialog()
|
||||||
|
ErrorDialog(_('Error'), str(error),
|
||||||
|
transient_for=file.control.parent_win.window)
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
file.stream = StreamFileWithProgress(file)
|
file.stream = StreamFileWithProgress(file)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
@@ -444,3 +455,7 @@ class ProgressWindow:
|
|||||||
class UploadAbortedException(Exception):
|
class UploadAbortedException(Exception):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Upload Aborted"
|
return "Upload Aborted"
|
||||||
|
|
||||||
|
class UnsecureTransportError(Exception):
|
||||||
|
def __str__(self):
|
||||||
|
return 'Server returned unsecure transport'
|
||||||
|
|||||||
Reference in New Issue
Block a user