Skip to content

Commit 47b7e07

Browse files
committed
fix:修复特殊符号被认为非法
1 parent 9739f21 commit 47b7e07

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

expr/expression.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,25 @@ func validateBasicSyntax(exprStr string) error {
131131
}
132132

133133
// Check for invalid characters
134+
inQuotes := false
135+
var quoteChar rune
136+
134137
for i, ch := range trimmed {
138+
// Handle quotes
139+
if ch == '\'' || ch == '"' {
140+
if !inQuotes {
141+
inQuotes = true
142+
quoteChar = ch
143+
} else if ch == quoteChar {
144+
inQuotes = false
145+
}
146+
}
147+
148+
// If inside quotes, skip character validation
149+
if inQuotes {
150+
continue
151+
}
152+
135153
// Allowed characters: letters, numbers, operators, parentheses, dots, underscores, spaces, quotes
136154
if !isValidChar(ch) {
137155
return fmt.Errorf("invalid character '%c' at position %d", ch, i)

0 commit comments

Comments
 (0)