Skip to content

Commit

Permalink
Fix the posisble index out of bounds error on stripping quotes. (#1471)
Browse files Browse the repository at this point in the history
Adds a length check to not try to strip quotes when the string is just a
"
  • Loading branch information
gmechali authored Nov 25, 2024
1 parent c2e3859 commit b5d6d7c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/translator/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ func removeConstraints(
}

func StripQuotes(str string) string {
if (strings.HasPrefix(str, "\"")) && (strings.HasSuffix(str, "\"")) {
if (len(str) > 1) && (strings.HasPrefix(str, "\"")) && (strings.HasSuffix(str, "\"")) {
str = str[1 : len(str)-1]
}
return str
Expand Down

0 comments on commit b5d6d7c

Please sign in to comment.