Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AlphaNumeric ¶
AlphaNumeric removes all non-alphanumeric characters.
Example:
safe := sanitize.AlphaNumeric("user-123!@#")
// Returns: "user123"
func HTML ¶
HTML escapes HTML special characters to prevent XSS attacks.
Example:
safe := sanitize.HTML("<script>alert('xss')</script>")
// Returns: "<script>alert('xss')</script>"
func IsEmail ¶
IsEmail validates if a string is a valid email format.
Example:
valid := sanitize.IsEmail("user@example.com") // true
valid := sanitize.IsEmail("invalid-email") // false
func IsURL ¶
IsURL validates if a string is a valid URL format.
Example:
valid := sanitize.IsURL("https://example.com") // true
valid := sanitize.IsURL("not-a-url") // false
func Path ¶
Path sanitizes file paths to prevent directory traversal attacks. Removes leading slashes and checks for attempts to escape the base directory.
Example:
safe := sanitize.Path("../../etc/passwd")
// Returns: "etc/passwd"
func StripTags ¶
StripTags removes all HTML/XML tags from a string.
Example:
clean := sanitize.StripTags("<p>Hello <b>World</b></p>")
// Returns: "Hello World"
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.