Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SanitizeUserInput ¶
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 ¶
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.