-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Open
Labels
area-System.Text.JsonenhancementProduct code improvement that does NOT require public API changes/additionsProduct code improvement that does NOT require public API changes/additions
Milestone
Description
Description
Deserializing Version does not allow leading nor trailing whitespace bug. But there are some wierd behaviours since the "components" of the version are parsed with NumberStyles.Integer:
+plus sign is allowed for second/third/fourth components.- Arbitrary amount of whitespace is allowed between the components and the
.dot-separateor.
Reproduction Steps
using System.Text.Json;
JsonSerializer.Deserialize<Version>($"\"+1.1\""); // Throws
JsonSerializer.Deserialize<Version>($"\"1.+1\""); // Success
JsonSerializer.Deserialize<Version>($"\" 1.1\""); // Throws
JsonSerializer.Deserialize<Version>($"\"1 .1\""); // Success
JsonSerializer.Deserialize<Version>($"\"1. 1\""); // Success
JsonSerializer.Deserialize<Version>($"\"1.1 \""); // Throws
JsonSerializer.Deserialize<Version>($"\"1 . +1\""); // Success
JsonSerializer.Deserialize<Version>($"\"1.{new string(' ', 255)}1\""); // Success
JsonSerializer.Deserialize<Version>($"\"1.{new string(' ', 256)}1\""); // Throws - string is too long (>258 chars)
Expected behavior
Not sure, but given the other JSON converters are a bit "strict" perhaps all of the above should throw?
Actual behavior
See repro steps
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-System.Text.JsonenhancementProduct code improvement that does NOT require public API changes/additionsProduct code improvement that does NOT require public API changes/additions