uploadpath

package
v0.116.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package uploadpath centralizes the on-disk location and filename sanitization for user-uploaded attachments so the WebUI upload handler and the Slack file-download path agree byte-for-byte.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dir

func Dir() string

Dir returns the directory where uploaded attachments are stored: {os.TempDir()}/kojo/upload. Callers create it on demand.

func SanitizeName

func SanitizeName(name string) string

SanitizeName reduces an arbitrary user-supplied filename to a single benign path component. The unified policy is:

  1. filepath.Base strips any directory components.
  2. "/", "\\" and NUL are replaced with "_".
  3. Any other control character (unicode.IsControl) is replaced with "_" — this blocks newline/escape-sequence injection through crafted names that later get echoed into prompts or logs.
  4. If the result would be "", "." or ".." (values that are unsafe as a bare path element), it is replaced with "_".

The output is safe to use directly as a filename component under Dir() and safe to join with a prefix ({unixnano}_{name}).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL