louislam / uptime-kuma

A fancy self-hosted monitoring tool
https://uptime.kuma.pet
MIT License
60.33k stars 5.4k forks source link

[SendMail] Email Address Friendly Name Error #5314

Closed valdearg closed 2 weeks ago

valdearg commented 2 weeks ago

📑 I have found these related issues/pull requests

NA

🛡️ Security Policy

Description

When selecting the SendGrid alert time and entering the "From Email" in the: name format, this gives a validation error:

image

If you click on the Test button, you get the email in the expected format, suggesting that this way of specifying the From Email is supported.

👟 Reproduction steps

On the Settings > Notifications tab, add a new notification type and select the SendGrid option. Enter the email address such as: Uptime Kuma test@test.com Select Test, if it's a valid email it will send. Select the Save button, the above field validation error will show.

👀 Expected behavior

I would expect this option to save without error.

😓 Actual Behavior

Validation error: A part followed by '@' should not contain the symbol ' '.

🐻 Uptime-Kuma Version

2.0.0-beta.0-nightly-20241105100611

💻 Operating System and Arch

Windows 11

🌐 Browser

Chrome 130.0.6723.92 (Official Build) (64-bit)

🖥️ Deployment Environment

📝 Relevant log output

No response

CommanderStorm commented 2 weeks ago

The code for this field can be found here:

https://github.com/louislam/uptime-kuma/blob/13ea190298a22fdb29e70accdc63df231dcdb73f/src/components/notifications/SendGrid.vue#L8

=> The frontend-validation is currently just type="email". If you/somebody else wants to look into how to best fix this issue, our Contribution guide can be found here: https://github.com/louislam/uptime-kuma/blob/13ea190298a22fdb29e70accdc63df231dcdb73f/CONTRIBUTING.md

ABHIGYAN-MOHANTA commented 2 weeks ago

@CommanderStorm

Thank you for providing the code location. I'd like to help fix this issue.

I'm thinking of modifying the input to accept the friendly name email format by:

  1. Changing the input type from "email" to "text"
  2. Adding regex pattern validation to accept format: "Friendly Name \email@domain.com\"
  3. Including proper validation feedback for incorrect formats

Would this approach align with what you're looking for? Happy to adjust the implementation based on your feedback before submitting a PR.

Apart from this I just want to confirm if this is correct:

Valid Formats

Invalid Formats

CommanderStorm commented 2 weeks ago

Invalid Formats

  • john@example.com

No, I think this would be a bug. The email alone is still valid.

Otherwise what I would expect.

ABHIGYAN-MOHANTA commented 2 weeks ago

Hey @CommanderStorm , does this look okay for a PR? Its applied to all email fields

https://github.com/user-attachments/assets/1c90e662-d2a0-4746-beb7-e1ffdc3327e5

CommanderStorm commented 2 weeks ago

does this look okay

that looks excellent 👍🏻 Feel free to submit a PR once you are ready

ABHIGYAN-MOHANTA commented 2 weeks ago

@CommanderStorm Done! Here's the PR: https://github.com/louislam/uptime-kuma/pull/5318 Please have a look, whenever you are free! Thanks!