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

Not all valid emails are accepted by the isValid method (utilized by Joi) #28

Closed
stevendesu opened this issue Apr 20, 2020 · 3 comments
Closed
Assignees
Labels
documentation Non-code related changes

Comments

@stevendesu
Copy link

Support plan

  • which support plan is this issue covered by? (e.g. Community, Core, Plus, or Enterprise): Community
  • is this issue currently blocking your project? (yes/no): no
  • is this issue affecting a production system? (yes/no): yes

Context

  • node version: v13.11.0
  • module version with issue: v4.0.1
  • last module version without issue: Unknown
  • environment (e.g. node, browser, native): Node
  • used with (e.g. hapi application, another framework, standalone, ...): Joi
  • any other relevant information:

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

Route definition:

server.route({
	method: "POST",
	path: "/register",
	options: {
		validate: {
			payload: {
				user: Joi.string().email().required(),
				password: Joi.string().min(8).required()
			}
		},
	},
	handler: async (request, h) =>
	{
		return "Got here";
	}
});

Request:

POST /register HTTP/1.1
Host: localhost:3000
User-Agent: curl/7.64.1
Accept: */*
Content-Type: application/json
Content-Length: 52

{"user":"\"one\"@email.com","password":"longenough"}

What was the result you got?

{"statusCode":400,"error":"Bad Request","message":"Invalid payload input"}

Using one@email.com instead of "one"@email.com works as expected

What result did you expect?

Got here
@stevendesu stevendesu added the support Questions, discussions, and general support label Apr 20, 2020
@hueniverse hueniverse added documentation Non-code related changes and removed support Questions, discussions, and general support labels May 21, 2020
@hueniverse hueniverse self-assigned this May 21, 2020
@hueniverse
Copy link
Contributor

Quoted emails are not supported. I update the joi documents to make it clear.

@stevendesu
Copy link
Author

Is there a reason quoted emails aren’t supported? Would a PR be considered that adds support?

If Joi is going to claim it does validation, I feel like the validation should be correct instead of arbitrarily deciding to mark things as false negatives.

@hueniverse
Copy link
Contributor

IIRC quoted local parts were not included because they are marked as obsolete in the RFC. joi claims to validate the things it validates. Quoted email support was intentionally dropped somewhere around v13 when I switched to use address instead of isemail which does support the entire email format possibilities.

If you need to support obsoleted email formats I suggest using isemail with a simple joi extension. I will not add support for it here because I don't want to maintain that code. The obsolete email formats are complex, add more size to the module, and should really not be used anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Non-code related changes
Projects
None yet
Development

No branches or pull requests

2 participants