Skip to content

Commit

Permalink
don't try parsing a string as an int/ float so we don't get any parsi…
Browse files Browse the repository at this point in the history
…ng errors due to invalid numbers

Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
  • Loading branch information
inteon committed Apr 22, 2023
1 parent c65c6c3 commit d5db06c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/markers/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,14 @@ func guessType(scanner *sc.Scanner, raw string, allowSlice bool) *Argument {

// parseString parses either of the two accepted string forms (quoted, or bare tokens).
func (a *Argument) parseString(scanner *sc.Scanner, raw string, out reflect.Value) {
// we need to temporarily disable the scanner's int/float parsing, since we want to
// prevent number parsing errors.
oldMode := scanner.Mode
scanner.Mode = oldMode &^ sc.ScanInts &^ sc.ScanFloats
defer func() {
scanner.Mode = oldMode
}()

// strings are a bit weird -- the "easy" case is quoted strings (tokenized as strings),
// the "hard" case (present for backwards compat) is a bare sequence of tokens that aren't
// a comma.
Expand Down

0 comments on commit d5db06c

Please sign in to comment.