Skip to content

Commit

Permalink
fix: don't parse numbers if potential to exceed 15 digits
Browse files Browse the repository at this point in the history
test: node -e "console.log(require('.')('9100000000000001'))"
  • Loading branch information
pi0 committed Nov 8, 2020
1 parent 74bda8b commit bc8c596
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.ts
Expand Up @@ -3,7 +3,7 @@
const suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/
const suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/

const JsonSigRx = /^["{[]|^-?[0-9][0-9.]*$/
const JsonSigRx = /^["{[]|^-?[0-9][0-9.]{0,14}$/

function jsonParseTransform (key: string, value: any): any {
if (key === '__proto__' || key === 'constructor') {
Expand Down

0 comments on commit bc8c596

Please sign in to comment.