Rev1855, Fix content type detection, Formatting

This commit is contained in:
shortcutme 2017-02-02 12:51:41 +01:00
parent 57a0d4f8a6
commit a08114b1b0
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
2 changed files with 4 additions and 5 deletions

View file

@ -10,7 +10,7 @@ class Config(object):
def __init__(self, argv): def __init__(self, argv):
self.version = "0.5.1" self.version = "0.5.1"
self.rev = 1852 self.rev = 1855
self.argv = argv self.argv = argv
self.action = None self.action = None
self.config_file = "zeronet.conf" self.config_file = "zeronet.conf"

View file

@ -201,7 +201,7 @@ class UiRequest(object):
return self.error403("Ajax request not allowed to load wrapper") # No ajax allowed on wrapper return self.error403("Ajax request not allowed to load wrapper") # No ajax allowed on wrapper
if self.isWebSocketRequest(): if self.isWebSocketRequest():
return self.error403("WebSocket request not allowed to load wrapper") # No websocket return self.error403("WebSocket request not allowed to load wrapper") # No websocket
if "text/html" not in self.env.get("HTTP_ACCEPT", ""): if "text/html" not in self.env.get("HTTP_ACCEPT", ""):
return self.error403("Invalid Accept header to load wrapper") return self.error403("Invalid Accept header to load wrapper")
@ -334,13 +334,12 @@ class UiRequest(object):
else: else:
return None return None
# Serve a media for site # Serve a media for site
def actionSiteMedia(self, path, header_length=True): def actionSiteMedia(self, path, header_length=True):
path_parts = self.parsePath(path) path_parts = self.parsePath(path)
# Check wrapper nonce # Check wrapper nonce
content_type = self.getContentType(path) content_type = self.getContentType(path_parts["inner_path"])
if "htm" in content_type: # Valid nonce must present to render html files if "htm" in content_type: # Valid nonce must present to render html files
wrapper_nonce = self.get.get("wrapper_nonce") wrapper_nonce = self.get.get("wrapper_nonce")
if wrapper_nonce not in self.server.wrapper_nonces: if wrapper_nonce not in self.server.wrapper_nonces:
@ -367,7 +366,7 @@ class UiRequest(object):
DebugMedia.merge(file_path) DebugMedia.merge(file_path)
if os.path.isfile(file_path): # File exists if os.path.isfile(file_path): # File exists
return self.actionFile(file_path, header_length=header_length) return self.actionFile(file_path, header_length=header_length)
elif os.path.isdir(file_path): # If this is actually a folder, add "/" and redirect elif os.path.isdir(file_path): # If this is actually a folder, add "/" and redirect
return self.actionRedirect("./{0}/".format(path_parts["inner_path"].split("/")[-1])) return self.actionRedirect("./{0}/".format(path_parts["inner_path"].split("/")[-1]))
else: # File not exists, try to download else: # File not exists, try to download
if address not in SiteManager.site_manager.sites: # Only in case if site already started downloading if address not in SiteManager.site_manager.sites: # Only in case if site already started downloading