-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Remove leading plus sign validation from Version JSON deserialization #118207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Copilot
wants to merge
16
commits into
main
Choose a base branch
from
copilot/fix-118201
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+46
−33
Open
Changes from 13 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
0dfae8c
Initial plan
Copilot 4a6c5e5
Fix Version deserialization to be more strict about edge cases
Copilot 4d36537
Make Version JSON deserialization more permissive to match Version.Pa…
Copilot c14d2ce
Remove length check and use conditional stackalloc with ArrayPool fal…
Copilot 6f6b2f5
Remove added comments to maintain original code style
Copilot cdb6fae
Move buffer return into finally block for VersionConverter
Copilot 28e315f
Reinstate original comments explaining validation logic
Copilot da19cc3
Remove leading plus sign validation check from VersionConverter
Copilot c4b7c8f
Update src/libraries/System.Text.Json/src/System/Text/Json/Serializat…
eiriktsarpalis 5741841
Simplify whitespace validation conditions in VersionConverter
Copilot a1bb358
Remove MinimumVersionLength constant and rename MaximumVersionLength …
Copilot 1da85ce
Merge branch 'main' into copilot/fix-118201
eiriktsarpalis 2f7ff2c
Add .NET 10+ optimization to parse Version directly from UTF8 bytes
Copilot 314f302
Use char.IsWhiteSpace instead of hardcoded space checks in UTF8 path
Copilot 5032d88
Use CopyString(Span<byte>) to enable UTF8 optimization for all inputs…
Copilot 1cfc81a
Remove .NET 10+ UTF8 optimization from VersionConverter to simplify w…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -336,6 +336,11 @@ public static void ValueFail() | |
| [InlineData("2147483647.2147483647.2147483647.2147483647")] | ||
| [InlineData("\\u0032\\u0031\\u0034\\u0037\\u0034\\u0038\\u0033\\u0036\\u0034\\u0037\\u002e\\u0032\\u0031\\u0034\\u0037\\u0034\\u0038\\u0033\\u0036\\u0034\\u0037\\u002e\\u0032\\u0031\\u0034\\u0037\\u0034\\u0038\\u0033\\u0036\\u0034\\u0037\\u002e\\u0032\\u0031\\u0034\\u0037\\u0034\\u0038\\u0033\\u0036\\u0034\\u0037", | ||
| "2147483647.2147483647.2147483647.2147483647")] | ||
| [InlineData("1.+1", "1.1")] // Plus in components should work as before | ||
| [InlineData("1 .1", "1.1")] // Whitespace before dot should work as before | ||
| [InlineData("1. 1", "1.1")] // Whitespace after dot should work as before | ||
| [InlineData("1 . +1", "1.1")] // Combined whitespace and plus should work as before | ||
| [InlineData("+1.1", "1.1")] // Leading plus should work | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also test against There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot ☝️ |
||
| public static void Version_Read_Success(string json, string? actual = null) | ||
| { | ||
| actual ??= json; | ||
|
|
@@ -348,16 +353,16 @@ public static void Version_Read_Success(string json, string? actual = null) | |
| [InlineData("")] | ||
| [InlineData(" ")] | ||
| [InlineData(" ")] | ||
| [InlineData(" 1.2.3.4")] // Leading whitespace should be rejected | ||
| [InlineData("1.2.3.4 ")] // Trailing whitespace should be rejected | ||
eiriktsarpalis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| [InlineData(" 1.2.3.4 ")] // Leading and trailing whitespace should be rejected | ||
| [InlineData("2147483648.2147483648.2147483648.2147483648")] //int.MaxValue + 1 | ||
| [InlineData("2147483647.2147483647.2147483647.21474836477")] // Slightly bigger in size than max length of Version | ||
| [InlineData("-2147483648.-2147483648")] | ||
| [InlineData("-2147483648.-2147483648.-2147483648")] | ||
| [InlineData("-2147483648.-2147483648.-2147483648.-2147483648")] | ||
| [InlineData("1.-1")] | ||
| [InlineData("1")] | ||
| [InlineData(" 1.2.3.4")] //Valid but has leading whitespace | ||
| [InlineData("1.2.3.4 ")] //Valid but has trailing whitespace | ||
| [InlineData(" 1.2.3.4 ")] //Valid but has trailing and leading whitespaces | ||
| [InlineData("{}", false)] | ||
| [InlineData("[]", false)] | ||
| [InlineData("true", false)] | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.