Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions backend/feed_engine/fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
import ssl
from dataclasses import dataclass
from urllib.error import HTTPError, URLError
from urllib.parse import urlsplit
from urllib.parse import urlsplit, urlunsplit
from urllib.request import HTTPSHandler, Request, build_opener

import certifi
Expand All @@ -133,15 +133,20 @@ def validate_url(url: str) -> str:
value = url.strip()
parts = urlsplit(value)

if parts.scheme not in {"http", "https"} or not parts.netloc:
if parts.scheme not in {"http", "https"} or not parts.netloc.strip():
raise FeedEngineError(
"INVALID_URL",
"Feed URL must be an absolute http or https URL.",
status_code=400,
context={"url": url},
)

print("[VALIDATE URL]", repr(url))
clean_netloc = parts.netloc.strip()
clean_path = parts.path.strip() or "/"
clean_query = parts.query.strip()
value = urlunsplit((parts.scheme, clean_netloc, clean_path, clean_query, ""))

print("[VALIDATE URL]", repr(url), "->", repr(value))
return value


Expand Down
6 changes: 6 additions & 0 deletions backend/scripts/build_sidecar.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from __future__ import annotations

import argparse
import os
import shutil
import subprocess
import sys
Expand Down Expand Up @@ -83,6 +84,9 @@ def build_binary(output_dir: str | None):
shutil.rmtree(DIST_DIR, ignore_errors=True)
shutil.rmtree(BUILD_DIR, ignore_errors=True)

schema_dir = BACKEND_DIR / "db" / "schema"
add_data_sep = ";" if sys.platform == "win32" else ":"

subprocess.run(
[
sys.executable,
Expand All @@ -95,6 +99,8 @@ def build_binary(output_dir: str | None):
"mercury-backend",
"--collect-all",
"certifi",
"--add-data",
f"{schema_dir}{add_data_sep}db{os.sep}schema",
str(SIDECAR_ENTRY),
],
check=True,
Expand Down
Loading