conditions

package
v4.2.13 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: GPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SanitizeUserInput

func SanitizeUserInput(conditional string) (sanitized string)

SanitizeUserInput sanitizes a conditional string provided by the user. Its main purpose is to convert other forms of precedence and logical operators to the condition grammar used. For example, some people may prefer a more verbose forms such as "dport=443 or dport=8080" or exotic forms such as "{dport=443 || dport=8080}". These should be caught and converted to the grammar-conforming expression "(dport=443|dport=8080)"

Input:

conditional: string containing the conditional specified in "user grammar"

Output:

string:  conditional string in the condition grammar. Note that this may still
         include syntactical errors or malspecified conditions. These will be caught
         at a latter stage
error:   any error from golang's regex module

func Tokenize

func Tokenize(condExpression string) ([]string, error)

Tokenize tokenizes the given conditional. Note that the tokenization is "loose": All valid conditionals will be correctly tokenized, but there are invalid conditionals that will also be tokenized. Its the parser's job to catch those. Whitespace in conditionals is only useful for tokenization and not needed afterwards. Tokenize doesn't emit any whitespace tokens.

Limitations: Only ASCII is supported. May give strange results on fancy Unicode strings.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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