Skip to content

Joi.string().email() passes for foo@bar%2ecom #2685

@arditshala

Description

@arditshala
  • is this issue currently blocking your project? (yes/no): yes
  • is this issue affecting a production system? (yes/no): yes

Context

  • node version: 12.x
  • module version with issue: ^17.4.2
  • last module version without issue: /
  • environment (e.g. node, browser, native): node
  • used with (e.g. hapi application, another framework, standalone, ...): standalone
  • any other relevant information:

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

I am using the e-mail validator so Joi.string().email().required() and I am expecting this method to have the RFC for e-mails structure implemented, i.e not allowing something like foo@bar%2ecom to be passed through, I know that %2e is . but if Joi lets this through at least the the output object that Joi produces should display the email as foo@bar.com, shouldn't it?

const Joi = require('joi');

const user = Joi.object({
  email: Joi.string().email().required()
});

What was the result you got?

No failure, the e-mail was passed

What result did you expect?

Either a validation error saying the e-mail is not corrects because it contains not allowed chars or the returned object produced by Joi to have the e-mail output as foo@bar.com instead of foo@bar%2ecom

Metadata

Metadata

Assignees

Labels

bugBug or defectdependencyUpdate module dependency

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions