MCPcopy Create free account
hub / github.com/foxcpp/maddy / validateNodeName

Function validateNodeName

framework/cfgparser/parse.go:74–94  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

72}
73
74func validateNodeName(s string) error {
75 if len(s) == 0 {
76 return errors.New("empty directive name")
77 }
78
79 if unicode.IsDigit([]rune(s)[0]) {
80 return errors.New("directive name cannot start with a digit")
81 }
82
83 allowedPunct := map[rune]bool{'.': true, '-': true, '_': true}
84
85 for _, ch := range s {
86 if !unicode.IsLetter(ch) &&
87 !unicode.IsDigit(ch) &&
88 !allowedPunct[ch] {
89 return errors.New("character not allowed in directive name: " + string(ch))
90 }
91 }
92
93 return nil
94}
95
96// readNode reads node starting at current token pointed by the lexer's
97// cursor (it should point to node name).

Callers 1

readNodeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected