Faker.js: faker.internet.email() may generate invalid email with other locales

Created on 29 Jul 2020  路  3Comments  路  Source: Marak/faker.js

When I'm trying to generate some email address under the "ja" locale, some email address are invalid.

To reproduce the issue, I use the browser's console from the demo page (https://rawgit.com/Marak/faker.js/master/examples/browser/index.html). Here's the input and output:

console.log(faker)
VM599:1 Faker聽{locales: {鈥, locale: "ja", localeFallback: "en", definitions: {鈥, fake: 茠,聽鈥
undefined
faker.locale = "ja"
"ja"
faker.internet.email()
"[email protected]"
faker.internet.email()
"[email protected]"
faker.internet.email()
"[email protected]"
faker.internet.email()
"[email protected]"
faker.internet.email()
"[email protected]"
faker.internet.email()
"[email protected]"
faker.internet.email()
"[email protected]"
faker.internet.email()
"[email protected]"

The email addresses that start with "." character are invalid. Please see https://en.wikipedia.org/wiki/Email_address#Syntax for the details.

Bug

Most helpful comment

If this is a legit issue, I could potentially open a PR to fix it.

All 3 comments

If this is a legit issue, I could potentially open a PR to fix it.

@clarmso -

Thank you for bringing this to our attention.

If you are able to open a PR to resolve this it would be much appreciated.

Thank you.

I open a PR for this, the same problem was happening with ch locales. The problem was because of this regex:
https://github.com/Marak/faker.js/blob/cb851b7656309e99ebbb61174f68d5e93e2ee147/lib/helpers.js#L28

This was removing the Japanese characters, so I just include them in the regex.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jnardone picture jnardone  路  6Comments

ghost picture ghost  路  4Comments

Deilan picture Deilan  路  3Comments

kevinburke picture kevinburke  路  5Comments

fauzanelka picture fauzanelka  路  4Comments