Skip to content

Decimal text and the integer wrapper sets' JSON still read a trailing NUL #251

Closed

Description

@CaffeinatedCoder

Problem

#233 (PR #242) refused a NUL in integer text, but two siblings still read 31\0 as 31. PostgreSQL text can't hold U+0000 (('31'||chr(0))::int → "null character not permitted"). Found by the final pre-release analysis on add665c.

  1. The decimal family. DecimalLiteral calls decimal.Parse with NumberStyles.Float, which ignores trailing NULs, and so does BigInteger.Parse in Represents.

    • DecimalRange.Parse("[31\0,40)") → [31,40), and DecimalRange.Finite.TryParse gives the same.
    • RangeSet<DecimalRange,decimal>.Parse and DecimalSet.Parse("{31\0}") → {31}, and DecimalSet<Money> likewise.
    • The TypeConverter, and JSON "[31\u0000,40)".
    • DecimalSet and DecimalSet<T> JSON ["31\u0000"] under AllowReadingFromString (ValueSetElementJson.ReadDecimalText), where System.Text.Json's own decimal converter throws.
    • "1.5\0" is refused, but only because the precision check counts the NUL as a fraction digit, so the message is wrong.

    PR fix: refuse a NUL in integer bounds and elements #242's description says the decimal family already refused NUL; it didn't.

  2. The integer wrapper arities' JSON. Int16Set<T>, Int32Set<T> and Int64Set<T> read ["31\u0000"] as {31} under AllowReadingFromString, while Int32Set and int[] throw JsonException. ValueSetElementJsonConverter.cs:60 (ReadIntegerText) runs long.TryParse(text, AllowLeadingSign, …), which accepts the NUL, then re-formats the number, so IntegerLiteral's check never sees it. This contradicts the 10.0.0 changelog line ("the wrapper sets, in a literal and JSON") and migration.md's "Send a wrapper set the JSON you send the plain set".

Silent; the first case is older than 10.0.0, so it is a tightening that belongs in this major.

Change

Refuse U+0000 at the top of DecimalLiteral.Parse and before the integer wrapper's long.TryParse (or hand the raw text to ParseValue). Sweep every numeric family's element and bound readers for the same BCL leniency.

Done when

31\0 and 1e2\0 are refused through ParseValue, the literal, and JSON under AllowReadingFromString, for DecimalRange, DecimalSet, DecimalSet<T> and the three integer wrapper arities. Each fails with its check removed. The changelog's NUL line names the decimal family too.

Activity

  1. added this to the 10.0.0 milestone on Oct 19, 2026
  2. added
    bug
    silent
    breaking
    area/value-sets
    on Oct 19, 2026
  3. added
    area/json
    area/literals
    package/core
    severity/low
    on Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/jsonarea/literalsarea/value-setsbreakingbugpackage/coreseverity/lowsilent

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions