forked from TrueCloudLab/frostfs-sdk-go
[#207] netmap: Fix string escape in PlacementPolicy.String()
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
a5fab572ff
commit
6fe4e2541d
2 changed files with 12 additions and 3 deletions
|
@ -940,10 +940,14 @@ func operationFromString(s string) (op netmap.Operation) {
|
|||
return
|
||||
}
|
||||
|
||||
// escapeString returns single quote wrapped string if it contains special
|
||||
// characters '-' and whitespace.
|
||||
// escapeString returns single quote wrapped string.
|
||||
// Wrapping rules must be kept in sync with QueryLexer.g4.
|
||||
// Currently only ASCII letters, digits and underscore can be parsed without quotes.
|
||||
func escapeString(s string) string {
|
||||
if strings.ContainsAny(s, " -\t") {
|
||||
for _, r := range s {
|
||||
if 'a' <= r && r <= 'z' || 'A' <= r && r <= 'Z' || '0' <= r && r <= '9' || r == '_' {
|
||||
continue
|
||||
}
|
||||
return "'" + s + "'"
|
||||
}
|
||||
return s
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue