fix:修复特殊符号被认为非法

This commit is contained in:
rulego-team
2025-12-16 11:34:30 +08:00
parent 9739f213e9
commit 47b7e07c6b

View File

@@ -131,7 +131,25 @@ func validateBasicSyntax(exprStr string) error {
}
// Check for invalid characters
inQuotes := false
var quoteChar rune
for i, ch := range trimmed {
// Handle quotes
if ch == '\'' || ch == '"' {
if !inQuotes {
inQuotes = true
quoteChar = ch
} else if ch == quoteChar {
inQuotes = false
}
}
// If inside quotes, skip character validation
if inQuotes {
continue
}
// Allowed characters: letters, numbers, operators, parentheses, dots, underscores, spaces, quotes
if !isValidChar(ch) {
return fmt.Errorf("invalid character '%c' at position %d", ch, i)