From 43a574225885c2d839e116b5a07ac0fb214048f9 Mon Sep 17 00:00:00 2001 From: shortcutme Date: Sun, 6 Oct 2019 03:20:16 +0200 Subject: [PATCH] Resolve domain in parsePath function --- plugins/Zeroname/UiRequestPlugin.py | 10 ---------- src/Ui/UiRequest.py | 4 ++++ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/plugins/Zeroname/UiRequestPlugin.py b/plugins/Zeroname/UiRequestPlugin.py index b0230524..eacb0aa0 100644 --- a/plugins/Zeroname/UiRequestPlugin.py +++ b/plugins/Zeroname/UiRequestPlugin.py @@ -11,16 +11,6 @@ class UiRequestPlugin(object): self.site_manager = SiteManager.site_manager super(UiRequestPlugin, self).__init__(*args, **kwargs) - # Media request - def actionSiteMedia(self, path, **kwargs): - match = re.match(r"/media/(?P
[A-Za-z0-9-]+\.[A-Za-z0-9\.-]+)(?P/.*|$)", path) - if match: # Its a valid domain, resolve first - domain = match.group("address") - address = self.site_manager.resolveDomain(domain) - if address: - path = "/media/" + address + match.group("inner_path") - return super(UiRequestPlugin, self).actionSiteMedia(path, **kwargs) # Get the wrapper frame output - @PluginManager.registerTo("ConfigPlugin") class ConfigPlugin(object): def createArguments(self): diff --git a/src/Ui/UiRequest.py b/src/Ui/UiRequest.py index 2aa87af2..fa3719e5 100644 --- a/src/Ui/UiRequest.py +++ b/src/Ui/UiRequest.py @@ -310,6 +310,7 @@ class UiRequest(object): # Renders a template def render(self, template_path, *args, **kwargs): template = open(template_path, encoding="utf8").read() + def renderReplacer(m): return "%s" % kwargs.get(m.group(1), "") @@ -559,6 +560,8 @@ class UiRequest(object): match = re.match(r"/media/(?P
[A-Za-z0-9]+[A-Za-z0-9\._-]+)(?P/.*|$)", path) if match: path_parts = match.groupdict() + if self.isDomain(path_parts["address"]): + path_parts["address"] = self.resolveDomain(path_parts["address"]) path_parts["request_address"] = path_parts["address"] # Original request address (for Merger sites) path_parts["inner_path"] = path_parts["inner_path"].lstrip("/") if not path_parts["inner_path"]: @@ -578,6 +581,7 @@ class UiRequest(object): return self.error404(path) address = path_parts["address"] + file_path = "%s/%s/%s" % (config.data_dir, address, path_parts["inner_path"]) if (config.debug or config.merge_media) and file_path.split("/")[-1].startswith("all."):