Check that status messages start with one of @#$
diff --git a/lang/parse/parse.go b/lang/parse/parse.go
index 5f443b9..050b2cb 100644
--- a/lang/parse/parse.go
+++ b/lang/parse/parse.go
@@ -32,6 +32,14 @@
return len(s) >= 2 && s[0] == '_' && s[1] == '_'
}
+func isStatusMessage(s string) bool {
+ if s == "" {
+ return false
+ }
+ c := s[0]
+ return (c == '@') || (c == '#') || (c == '$')
+}
+
func Parse(tm *t.Map, filename string, src []t.Token, opts *Options) (*a.File, error) {
p := &parser{
tm: tm,
@@ -220,6 +228,10 @@
got := p.tm.ByID(message)
return nil, fmt.Errorf(`parse: expected string literal, got %q at %s:%d`, got, p.filename, p.line())
}
+ if s, _ := t.Unescape(p.tm.ByID(message)); !isStatusMessage(s) {
+ return nil, fmt.Errorf(`parse: status message %q does not start with `+
+ `@, # or $ at %s:%d`, s, p.filename, p.line())
+ }
p.src = p.src[1:]
if x := p.peek1(); x != t.IDSemicolon {
got := p.tm.ByID(x)