Repository navigation
fix(common): reject non-numeric items in ParseArrayPipe with items Number - #17876
Merged
kamilmysliwiec merged 1 commit intoSep 25, 2026
Merged
kamilmysliwiec merged 1 commit into
kamilmysliwiec merged 1 commit into
Conversation
…mber ParseArrayPipe validated Number items with `+value` after JSON.parse, so anything that coerces to a number passed: `true` became 1, `false` 0, `[2]` 2, a blank item 0, `0x10` 16 and `Infinity` Infinity. Only accept finite numbers and numeric strings, and reject radix prefixes the same way ParseIntPipe and ParseFloatPipe do.
4 of 12 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
With
new ParseArrayPipe({ items: Number }), each item goes throughJSON.parseand is then checked with+value/isNaN. Anything that coerces to a number passes:?ids=1,true[1, 1]?ids=1,false[1, 0]?ids=1,[2][1, 2]?ids=1, ,2[1, 0, 2]?ids=1,0x10[1, 16]?ids=1,Infinity[1, Infinity][1, true][1, 1]ParseIntPipeandParseFloatPipereject all of these.Issue Number: N/A
What is the new behavior?
Number items must be a finite number, or a non-blank string that
Number()turns into a finite number without a0x/0b/0oprefix (the same prefixesParseFloatPiperejects). Anything else fails with the existing[i] item must be a numbermessage. Numeric strings that passed before still pass (1,2,-3.5,1e3,01,+4,.5).Two tests were added to
parse-array.pipe.spec.ts. On master, the first fails withpromise resolved "[ 1, 1 ]" instead of rejecting. With this change, the 212 tests inpackages/common/test/pipespass, and oxlint and prettier report no problems on the changed files.Does this PR introduce a breaking change?
Other information
Arrays that pass validation are unchanged. The only inputs this now rejects are values that were being silently turned into numbers.