From 2897c24e838b64e14aa273602b9dea5ff65f3fc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Maldonado?= Date: Tue, 3 Jan 2023 11:19:09 +0100 Subject: [PATCH] Percent-encode org_name in links If org_name contains spaces, the generated link will not work in some email clients unless it is percent-encoded --- src/mail.rs | 1 + src/static/templates/email/send_org_invite.hbs | 2 +- src/static/templates/email/send_org_invite.html.hbs | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mail.rs b/src/mail.rs index af0f8c7c..c77f406e 100644 --- a/src/mail.rs +++ b/src/mail.rs @@ -245,6 +245,7 @@ pub async fn send_invite( "org_id": org_id.as_deref().unwrap_or("_"), "org_user_id": org_user_id.as_deref().unwrap_or("_"), "email": percent_encode(address.as_bytes(), NON_ALPHANUMERIC).to_string(), + "org_name_encoded": percent_encode(org_name.as_bytes(), NON_ALPHANUMERIC).to_string(), "org_name": org_name, "token": invite_token, }), diff --git a/src/static/templates/email/send_org_invite.hbs b/src/static/templates/email/send_org_invite.hbs index b35314fc..be94d0e5 100644 --- a/src/static/templates/email/send_org_invite.hbs +++ b/src/static/templates/email/send_org_invite.hbs @@ -3,7 +3,7 @@ Join {{{org_name}}} You have been invited to join the *{{org_name}}* organization. -Click here to join: {{url}}/#/accept-organization/?organizationId={{org_id}}&organizationUserId={{org_user_id}}&email={{email}}&organizationName={{org_name}}&token={{token}} +Click here to join: {{url}}/#/accept-organization/?organizationId={{org_id}}&organizationUserId={{org_user_id}}&email={{email}}&organizationName={{org_name_encoded}}&token={{token}} If you do not wish to join this organization, you can safely ignore this email. diff --git a/src/static/templates/email/send_org_invite.html.hbs b/src/static/templates/email/send_org_invite.html.hbs index 003eb504..55b98145 100644 --- a/src/static/templates/email/send_org_invite.html.hbs +++ b/src/static/templates/email/send_org_invite.html.hbs @@ -9,7 +9,7 @@ Join {{{org_name}}} - Join Organization Now