form

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package form provides functions for providing data for form and input elements.

Index

Constants

View Source
const ReSanitizePath = "[^a-zA-Z0-9-._/]+" // Regular expression to sanitize the URL path.

Variables

This section is empty.

Functions

func HumanizeCount

func HumanizeCount(db *sql.DB, section, platform string) (template.HTML, error)

HumanizeCount returns the human readable name of the platform and section tags combined and the number of existing artifacts. The number of existing artifacts is colored based on the count. If the count is 0, the text is red. If the count is 1, the text is blue. If the count is greater than 1, the text is unmodified.

func HumanizeCountStr

func HumanizeCountStr(db *sql.DB, section, platform string) string

HumanizeCountStr returns the human readable name of the platform and section tags combined and the number of existing artifacts. Any errors are returned as a string.

func SanitizeFilename

func SanitizeFilename(name string) string

SanitizeFilename returns a sanitized version of the filename. The filename is trimmed of any leading or trailing whitespace, and any parent directory references are removed. Any Linux or Windows directory separators are replaced with a "-" hyphen.

func SanitizeGitHub

func SanitizeGitHub(repo string) string

SanitizeGitHub returns a sanitized version of the GitHub repository. The repo is trimmed of any invalid characters listed in the GitHub documentation.

func SanitizeSeparators

func SanitizeSeparators(rawPath string) string

SanitizeSeparators returns a sanitized version of the URL path. The path is trimmed of any URL scheme, host or query parameters, as well as any invalid path separators.

func SanitizeURLPath

func SanitizeURLPath(rawPath string) string

SanitizeURLPath returns a sanitized version of the URL path. Invalid characters are removed as are as incorrect path separators.

func ValidDate

func ValidDate(y, m, d string) (bool, bool, bool)

ValidDate returns three boolean values that indicate if the year, month, and day are valid. If any of the bool values are false, the date syntax is invalid and should not be used.

The year must be between 1980 and the current year. If the year is not in use, the month and day must not be in use. And if the month is not in use, the day must not in use.

A not in use value is either "0" or an empty string.

func ValidVT

func ValidVT(link string) bool

ValidVT returns true if the link is a valid VirusTotal URL or if it is an empty string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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