Skip to content

base64 validation returns RangeError #1700

@AlbertHambardzumyan

Description

@AlbertHambardzumyan

Context

  • node version: v10.15.0
  • joi version: v14.0.0
  • environment (node, browser): node
  • used with (hapi, standalone, ...): standalone
  • any other relevant information:

What are you trying to achieve or the steps to reproduce ?

const schema = Joi.string().base64()

const length = 4473955
let data = 'ACAgICAgICApXG4gICAgICAgICDcDdAgICAgIClXbi'
while (data.length < length) {
   data += 'ACAgICAgICApXG4gICAgICAgICDcDdAgICAgIClXbi'
}
data = data.substring(0, length)

const buffer = Buffer.from(data)
const value = buffer.toString('base64')

Which result you had ?

RangeError: Maximum call stack size exceeded

What did you expect ?

const { error } = Joi.validate(value, schema) // NO error should be here

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug or defect

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions