Revert to 8c23e9d811
All checks were successful
Datadog Software Composition Analysis / Datadog SBOM Generation and Upload (push) Successful in 51s
Datadog Secrets Scanning / Datadog Static Analyzer (push) Successful in 56s
Release / build (push) Successful in 1m24s
Release / publish_head (push) Successful in 1m17s
Datadog Static Analysis / Datadog Static Analyzer (push) Successful in 5m41s
All checks were successful
Datadog Software Composition Analysis / Datadog SBOM Generation and Upload (push) Successful in 51s
Datadog Secrets Scanning / Datadog Static Analyzer (push) Successful in 56s
Release / build (push) Successful in 1m24s
Release / publish_head (push) Successful in 1m17s
Datadog Static Analysis / Datadog Static Analyzer (push) Successful in 5m41s
This commit is contained in:
@ -1,11 +1,9 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from flask import request, send_file
|
||||
|
||||
from src.config.config import Configuration
|
||||
from src.rendering.renderer import render_page, render_error_page
|
||||
from flask import send_file, request
|
||||
from src.rendering.image import generate_thumbnail
|
||||
from src.rendering.renderer import render_error_page, render_page
|
||||
import os
|
||||
|
||||
|
||||
class RouteManager:
|
||||
@ -34,6 +32,7 @@ class RouteManager:
|
||||
|
||||
for part in secure_path_parts:
|
||||
if part == "." or part == "..":
|
||||
print("Illegal path nice try")
|
||||
return None
|
||||
|
||||
# Reconstruct the secure path
|
||||
@ -46,15 +45,13 @@ class RouteManager:
|
||||
|
||||
for part in secure_path.parts:
|
||||
if part.startswith("___"):
|
||||
print("hidden file")
|
||||
raise Exception("Illegal path")
|
||||
|
||||
return secure_path
|
||||
|
||||
def _ensure_route(self, path: str):
|
||||
file_path: Path = self.config.content_dir / path
|
||||
if not path or file_path.is_dir():
|
||||
file_path = file_path / "index.md"
|
||||
|
||||
file_path: Path = self.config.content_dir / (path if path else "index.md")
|
||||
if file_path < self.config.content_dir:
|
||||
raise Exception("Illegal path")
|
||||
|
||||
@ -73,9 +70,7 @@ class RouteManager:
|
||||
"The requested resource was not found on this server.",
|
||||
self.config.templates_dir,
|
||||
)
|
||||
file_path: Path = self.config.content_dir / path
|
||||
if not path or file_path.is_dir():
|
||||
file_path = file_path / "index.md"
|
||||
file_path: Path = self.config.content_dir / (path if path else "index.md")
|
||||
return render_page(
|
||||
file_path,
|
||||
base_path=self.config.content_dir,
|
||||
@ -125,10 +120,8 @@ class RouteManager:
|
||||
return (
|
||||
thumbnail_bytes,
|
||||
200,
|
||||
{
|
||||
"Content-Type": f"image/{img_format.lower()}",
|
||||
"cache-control": "public, max-age=31536000",
|
||||
},
|
||||
{"Content-Type": f"image/{img_format.lower()}",
|
||||
"cache-control": "public, max-age=31536000"},
|
||||
)
|
||||
return send_file(file_path)
|
||||
else:
|
||||
|
Reference in New Issue
Block a user