fix: sanitize pdf font path
This commit is contained in:
@@ -18,14 +18,17 @@ func resolvePdfAssetPath(name string) (string, error) {
|
|||||||
return "", fmt.Errorf("env PDF_FONT_DIR not set")
|
return "", fmt.Errorf("env PDF_FONT_DIR not set")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mutlaka absolute olsun
|
if !strings.HasPrefix(base, "/") {
|
||||||
if !filepath.IsAbs(base) {
|
base = "/" + base
|
||||||
return "", fmt.Errorf("PDF_FONT_DIR must be absolute: %s", base)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
full := filepath.Clean(filepath.Join(base, name))
|
name = strings.TrimSpace(name)
|
||||||
|
name = strings.TrimPrefix(name, "/")
|
||||||
|
name = strings.TrimPrefix(name, "\\")
|
||||||
|
|
||||||
|
full := filepath.Join(base, name)
|
||||||
|
full = filepath.Clean(full)
|
||||||
|
|
||||||
// DEBUG
|
|
||||||
log.Printf("📄 PDF FONT PATH = %s", full)
|
log.Printf("📄 PDF FONT PATH = %s", full)
|
||||||
|
|
||||||
if _, err := os.Stat(full); err != nil {
|
if _, err := os.Stat(full); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user