diff options
-rw-r--r-- | main.go | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -4,6 +4,7 @@ import ( "fmt" "io" "os" + "regexp" "strings" ) @@ -52,6 +53,15 @@ func firstPass( parts := strings.Split(line, ":") for _, label := range parts[:len(parts)-1] { label = strings.TrimSpace(strings.ToUpper(label)) + isCharsetAllowed := regexp.MustCompile(`^[a-zA-Z0-9_-]*$`).MatchString(label) + if !isCharsetAllowed { + return nil, fmt.Errorf( + "File %s, line %d:\nLabel \"%s\" contains special characters. Only alphanumeric, dashes and underscores are allowed", + input_file_name, + line_nb+1, + label, + ) + } if _, ok := state.Labels[label]; ok { return nil, fmt.Errorf( "File %s, line %d:\nLabel %s is already defined", |