Skip to content

Commit

Permalink
Merge pull request HelloZeroNet#749 from MuxZeroNet/patch-3
Browse files Browse the repository at this point in the history
WebSocket requests not allowed
  • Loading branch information
HelloZeroNet committed Jan 8, 2017
2 parents 86bba4f + 0a1eece commit 5f567c3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Ui/UiRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ def route(self, path):
def isProxyRequest(self):
return self.env["PATH_INFO"].startswith("http:https://")

def isWebSocket(self):
return self.env.get("HTTP_UPGRADE") == "websocket"

def isAjaxRequest(self):
return self.env.get("HTTP_X_REQUESTED_WITH") == "XMLHttpRequest"

Expand Down Expand Up @@ -195,7 +198,9 @@ def actionWrapper(self, path, extra_headers=None):
return self.actionSiteMedia("/media" + path) # Only serve html files with frame
if self.isAjaxRequest():
return self.error403("Ajax request not allowed to load wrapper") # No ajax allowed on wrapper

if self.isWebSocket():
return self.error403("WebSocket not allowed to load wrapper") # No websocket

if "text/html" not in self.env["HTTP_ACCEPT"]:
return self.error403("Invalid Accept header to load wrapper")
if "prefetch" in self.env.get("HTTP_X_MOZ", "") or "prefetch" in self.env.get("HTTP_PURPOSE", ""):
Expand Down

0 comments on commit 5f567c3

Please sign in to comment.