RocketChat / Rocket.Chat

The communications platform that puts data protection first.
https://rocket.chat/
Other
40.7k stars 10.67k forks source link

Transcribe From: e-mail regexp does not support TLD-s longer than 4 char #22113

Open krisavi opened 3 years ago

krisavi commented 3 years ago

Description:

The transcript From: email gets parts cut off or mail is not sent when TLD should be longer than 4 char (like .casino, .luxury, .photo, .photography, .consulting, etc) Part is getting cut off from something like rocketchat@subdomain.dmn.photo and ends up being rocketchat@subdomain.dmn

The regexp to check the e-mail does not support for TLD-s that can be longer than 4 characters due to this issue it cuts off the last part of "From: " if using something like subdomain.domain.photo.

Steps to reproduce:

  1. Set up e-mail with longer than 4 char TLD
  2. Send transcript
  3. Check From: address

Expected behavior:

Full From: address in e-mail headers

Actual behavior:

TLD is being cut off if domain part is short like 3-4 char.

Server Setup Information:

Server info irrelevant, as issue is in code base from it's creation commit.

Client info irrelevant, as issue is in code base from it's creation commit.

Additional context

Errors located here in regexp! https://github.com/RocketChat/Rocket.Chat/blob/157b882d38b34b7b79dea527316554fe33f70891/app/livechat/server/lib/Livechat.js#L994

https://github.com/RocketChat/Rocket.Chat/blob/develop/app/livechat/server/lib/Livechat.js#L997

https://github.com/RocketChat/Rocket.Chat/blob/157b882d38b34b7b79dea527316554fe33f70891/app/livechat/server/lib/Livechat.js#L1079

https://github.com/RocketChat/Rocket.Chat/blob/develop/app/livechat/server/lib/Livechat.js#L1082

Relevant logs:

N/A It is code error, location pointed out to you above.

johncrisp commented 3 years ago

Hi and thanks for reporting this.

Two quick questions. Is this a regression?

Second, can you please test this on the latest code just to be sure and confirm it is still there?

krisavi commented 3 years ago

It seems to be in the code since it's creation. Seems to be in there even in develop as you can follow links below to see in current code base https://github.com/RocketChat/Rocket.Chat/blob/develop/app/livechat/server/lib/Livechat.js#L997 https://github.com/RocketChat/Rocket.Chat/blob/develop/app/livechat/server/lib/Livechat.js#L1082

On local copy I replaced in /opt/Rocket.Chat/programs/server/app/app.js the following:

let fromEmail = settings.get('From_Email').match(/\b[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}\b/i);
if (fromEmail) {
    fromEmail = fromEmail[0];
} else {
    fromEmail = settings.get('From_Email');
}

to let fromEmail = settings.get('From_Email')

Restarted the service and it worked fine.

krisavi commented 3 years ago

Problem seems to be still there: let fromEmail = settings.get('From_Email').match(/\b[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}\b/i); The main issue there is [A-Z]{2,4} that limits the TLD to 2 to 4 characters and will not work with a lot of domains added with https://icannwiki.org/New_gTLD_Program

Since some lines have changed in the file the lines are currently: https://github.com/RocketChat/Rocket.Chat/blob/develop/app/livechat/server/lib/Livechat.js#L1075 and https://github.com/RocketChat/Rocket.Chat/blob/develop/app/livechat/server/lib/Livechat.js#L1176