Fix DeprecationWarning: invalid escape sequence
Signed-off-by: Mickaël Schoentgen <contact@tiger-222.fr>
This commit is contained in:
parent
4c675b8311
commit
e8298726ca
13 changed files with 20 additions and 20 deletions
|
@ -198,7 +198,7 @@ class SitePlugin(object):
|
|||
return False
|
||||
|
||||
def fileForgot(self, inner_path):
|
||||
if "|" in inner_path and self.content_manager.isPinned(re.sub("\|.*", "", inner_path)):
|
||||
if "|" in inner_path and self.content_manager.isPinned(re.sub(r"\|.*", "", inner_path)):
|
||||
self.log.debug("File %s is pinned, no fileForgot" % inner_path)
|
||||
return False
|
||||
else:
|
||||
|
@ -206,7 +206,7 @@ class SitePlugin(object):
|
|||
|
||||
def fileDone(self, inner_path):
|
||||
if "|" in inner_path and self.bad_files.get(inner_path, 0) > 5: # Idle optional file done
|
||||
inner_path_file = re.sub("\|.*", "", inner_path)
|
||||
inner_path_file = re.sub(r"\|.*", "", inner_path)
|
||||
num_changed = 0
|
||||
for key, val in self.bad_files.items():
|
||||
if key.startswith(inner_path_file) and val > 1:
|
||||
|
|
|
@ -31,7 +31,7 @@ class SiteManagerPlugin(object):
|
|||
|
||||
# Return: True if the address is .bit domain
|
||||
def isBitDomain(self, address):
|
||||
return re.match("(.*?)([A-Za-z0-9_-]+\.bit)$", address)
|
||||
return re.match(r"(.*?)([A-Za-z0-9_-]+\.bit)$", address)
|
||||
|
||||
# Resolve domain
|
||||
# Return: The address or None
|
||||
|
|
|
@ -13,7 +13,7 @@ class UiRequestPlugin(object):
|
|||
|
||||
# Media request
|
||||
def actionSiteMedia(self, path, **kwargs):
|
||||
match = re.match("/media/(?P<address>[A-Za-z0-9-]+\.[A-Za-z0-9\.-]+)(?P<inner_path>/.*|$)", path)
|
||||
match = re.match(r"/media/(?P<address>[A-Za-z0-9-]+\.[A-Za-z0-9\.-]+)(?P<inner_path>/.*|$)", path)
|
||||
if match: # Its a valid domain, resolve first
|
||||
domain = match.group("address")
|
||||
address = self.site_manager.resolveDomain(domain)
|
||||
|
|
|
@ -24,7 +24,7 @@ class SiteManagerPlugin(object):
|
|||
|
||||
# Return: True if the address is domain
|
||||
def isDomain(self, address):
|
||||
return re.match("(.*?)([A-Za-z0-9_-]+\.[A-Za-z0-9]+)$", address)
|
||||
return re.match(r"(.*?)([A-Za-z0-9_-]+\.[A-Za-z0-9]+)$", address)
|
||||
|
||||
|
||||
# Load dns entries from data/dns_cache.json
|
||||
|
@ -74,7 +74,7 @@ class SiteManagerPlugin(object):
|
|||
if not sub_domain: sub_domain = "@"
|
||||
address = None
|
||||
with gevent.Timeout(5, Exception("Timeout: 5s")):
|
||||
res = Http.get("https://dnschain.info/bit/d/%s" % re.sub("\.bit$", "", top_domain)).read()
|
||||
res = Http.get("https://dnschain.info/bit/d/%s" % re.sub(r"\.bit$", "", top_domain)).read()
|
||||
data = json.loads(res)["value"]
|
||||
for key, val in data["zeronet"].iteritems():
|
||||
self.dns_cache[key+"."+top_domain] = [val, time.time()+60*60*5] # Cache for 5 hours
|
||||
|
|
|
@ -11,7 +11,7 @@ class UiRequestPlugin(object):
|
|||
|
||||
# Media request
|
||||
def actionSiteMedia(self, path):
|
||||
match = re.match("/media/(?P<address>[A-Za-z0-9-]+\.[A-Za-z0-9\.-]+)(?P<inner_path>/.*|$)", path)
|
||||
match = re.match(r"/media/(?P<address>[A-Za-z0-9-]+\.[A-Za-z0-9\.-]+)(?P<inner_path>/.*|$)", path)
|
||||
if match: # Its a valid domain, resolve first
|
||||
domain = match.group("address")
|
||||
address = self.site_manager.resolveDomain(domain)
|
||||
|
@ -23,7 +23,7 @@ class UiRequestPlugin(object):
|
|||
# Is mediarequest allowed from that referer
|
||||
def isMediaRequestAllowed(self, site_address, referer):
|
||||
referer_path = re.sub("http[s]{0,1}://.*?/", "/", referer).replace("/media", "") # Remove site address
|
||||
referer_site_address = re.match("/(?P<address>[A-Za-z0-9\.-]+)(?P<inner_path>/.*|$)", referer_path).group("address")
|
||||
referer_site_address = re.match(r"/(?P<address>[A-Za-z0-9\.-]+)(?P<inner_path>/.*|$)", referer_path).group("address")
|
||||
|
||||
if referer_site_address == site_address: # Referer site address as simple address
|
||||
return True
|
||||
|
|
|
@ -19,4 +19,4 @@ class UiRequestPlugin(object):
|
|||
</html>
|
||||
"""
|
||||
|
||||
return re.sub("</body>\s*</html>\s*$", inject_html, body)
|
||||
return re.sub(r"</body>\s*</html>\s*$", inject_html, body)
|
||||
|
|
|
@ -56,7 +56,7 @@ class UiRequestPlugin(object):
|
|||
|
||||
# Redirect to homepage or referer
|
||||
url = self.env.get("HTTP_REFERER", "")
|
||||
if not url or re.sub("\?.*", "", url).endswith("/Login"):
|
||||
if not url or re.sub(r"\?.*", "", url).endswith("/Login"):
|
||||
url = "/" + config.homepage
|
||||
cookie_header = ('Set-Cookie', "session_id=%s;path=/;max-age=2592000;" % session_id) # Max age = 30 days
|
||||
self.start_response('301 Redirect', [('Location', url), cookie_header])
|
||||
|
|
|
@ -25,7 +25,7 @@ class SiteManagerPlugin(object):
|
|||
|
||||
# Return: True if the address is domain
|
||||
def isDomain(self, address):
|
||||
return re.match("(.*?)([A-Za-z0-9_-]+\.[A-Za-z0-9]+)$", address)
|
||||
return re.match(r"(.*?)([A-Za-z0-9_-]+\.[A-Za-z0-9]+)$", address)
|
||||
|
||||
|
||||
# Resolve domain
|
||||
|
|
|
@ -11,7 +11,7 @@ class UiRequestPlugin(object):
|
|||
|
||||
# Media request
|
||||
def actionSiteMedia(self, path):
|
||||
match = re.match("/media/(?P<address>[A-Za-z0-9-]+\.[A-Za-z0-9\.-]+)(?P<inner_path>/.*|$)", path)
|
||||
match = re.match(r"/media/(?P<address>[A-Za-z0-9-]+\.[A-Za-z0-9\.-]+)(?P<inner_path>/.*|$)", path)
|
||||
if match: # Its a valid domain, resolve first
|
||||
domain = match.group("address")
|
||||
address = self.site_manager.resolveDomain(domain)
|
||||
|
@ -23,13 +23,13 @@ class UiRequestPlugin(object):
|
|||
# Is mediarequest allowed from that referer
|
||||
def isMediaRequestAllowed(self, site_address, referer):
|
||||
referer_path = re.sub("http[s]{0,1}://.*?/", "/", referer).replace("/media", "") # Remove site address
|
||||
referer_path = re.sub("\?.*", "", referer_path) # Remove http params
|
||||
referer_path = re.sub(r"\?.*", "", referer_path) # Remove http params
|
||||
|
||||
if self.isProxyRequest(): # Match to site domain
|
||||
referer = re.sub("^http://zero[/]+", "http://", referer) # Allow /zero access
|
||||
referer_site_address = re.match("http[s]{0,1}://(.*?)(/|$)", referer).group(1)
|
||||
else: # Match to request path
|
||||
referer_site_address = re.match("/(?P<address>[A-Za-z0-9\.-]+)(?P<inner_path>/.*|$)", referer_path).group("address")
|
||||
referer_site_address = re.match(r"/(?P<address>[A-Za-z0-9\.-]+)(?P<inner_path>/.*|$)", referer_path).group("address")
|
||||
|
||||
if referer_site_address == site_address: # Referer site address as simple address
|
||||
return True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue