Skip to content
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

base64 validation #1055

Closed
indreek opened this issue Dec 5, 2016 · 3 comments
Closed

base64 validation #1055

indreek opened this issue Dec 5, 2016 · 3 comments
Assignees
Labels
non issue Issue is not a problem or requires changes

Comments

@indreek
Copy link

indreek commented Dec 5, 2016

Context

  • node version: 7.0.0
  • joi version: 10.0.2
  • environment (node, browser):node
  • used with (hapi, standalone, ...):hapi
  • any other relevant information:

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

{
    method: 'POST',
    path: '/account/register',
    handler: (request, reply)=>{reply('Done')},
    config: {
      description: 'Register new user account',
      validate: {
        payload: Joi.object({
          username: Joi.string().email().required(),
          password: Joi.string().base64().min(8).required()
        })
      }
    }
  }

Which result you had ?

Im sending this payload and i get response done!
{
"username": "test@test.com",
"password": "password"
}

What did you expect ?

Is there an option to validate length of decoded string? Currently password decoding returns empty string, buy Joi doesn't see problem. Maybe it should check length after decoding string? Is there such an option?

Indrek

@Marsup Marsup closed this as completed in a959139 Dec 5, 2016
@Marsup Marsup added the bug Bug or defect label Dec 5, 2016
@Marsup Marsup self-assigned this Dec 5, 2016
@Marsup Marsup added this to the 10.0.4 milestone Dec 5, 2016
@Marsup
Copy link
Collaborator

Marsup commented Dec 5, 2016

This was a bug in base64 validation, now fixed. I don't plan on making those rules interact with each other right now.

@indreek
Copy link
Author

indreek commented Dec 5, 2016

It doesn't understand everything.
Aa123123! = QWExMjMxMjMh
Joi says: child "password" fails because ["password" must be a valid base64 string]

Marsup added a commit that referenced this issue Dec 5, 2016
@Marsup Marsup reopened this Dec 5, 2016
@Marsup Marsup removed this from the 10.0.4 milestone Dec 5, 2016
@Marsup Marsup added non issue Issue is not a problem or requires changes and removed bug Bug or defect labels Dec 5, 2016
@Marsup
Copy link
Collaborator

Marsup commented Dec 5, 2016

I reverted the patch as the previous regexp wasn't that bad after all, password is a valid base64 string, and it's not empty.

@Marsup Marsup closed this as completed Dec 5, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Jan 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
non issue Issue is not a problem or requires changes
Projects
None yet
Development

No branches or pull requests

2 participants