fix: enforce absolute pdf font path

This commit is contained in:
2026-02-16 12:25:54 +03:00
parent 2f9c917a08
commit a514f4dcfa

View File

@@ -2,6 +2,7 @@ package routes
import ( import (
"fmt" "fmt"
"log"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@@ -17,16 +18,15 @@ func resolvePdfAssetPath(name string) (string, error) {
return "", fmt.Errorf("env PDF_FONT_DIR not set") return "", fmt.Errorf("env PDF_FONT_DIR not set")
} }
// Absolute yap // Mutlaka absolute olsun
base, err := filepath.Abs(base) if !filepath.IsAbs(base) {
if err != nil { return "", fmt.Errorf("PDF_FONT_DIR must be absolute: %s", base)
return "", err
} }
full := filepath.Join(base, name) full := filepath.Clean(filepath.Join(base, name))
// Debug log // DEBUG
fmt.Println("PDF FONT PATH:", full) log.Printf("📄 PDF FONT PATH = %s", full)
if _, err := os.Stat(full); err != nil { if _, err := os.Stat(full); err != nil {
return "", fmt.Errorf("font not found: %s (%v)", full, err) return "", fmt.Errorf("font not found: %s (%v)", full, err)