dduan/TOMLDecoder

Float parsing skips frac parsing if 0 is first digit after decimal

Solidsilver opened this issue · 0 comments

Issue

The function normalFloat(_ input: inout Substring) does not correctly parse floats. After parsing the decimal, it calls decIntTextUTF8(_ utf8: inout Substring.UTF8View) again. This function checks to make sure the first digit is not zero. However, with the fractional component of floats this is allowed.

The result of this bug is that floats parsed that fit this condition (ex: 12.02, -325.0021) will return without the digits following the first 0, and those remaining digits will be left on input causing a parsing error.

Suggested solution:

Create a separate function to be called after the decimal which does not perform this first-digit zero-check.