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

Cannot use "tel:" links #65

Open
sklinkert opened this issue Apr 4, 2020 · 3 comments
Open

Cannot use "tel:" links #65

sklinkert opened this issue Apr 4, 2020 · 3 comments

Comments

@sklinkert
Copy link

I want to add a button containing a phone number linke this:

email := hermes.Email{}
email.Body.Actions = append(email.Body.Actions, hermes.Action{
	Instructions: lp.Sprintf("Use this button to call sender"),
	Button: hermes.Button{
		Color: "#57cbcc",
		Text:  "Call",
		Link: "tel:0123456789",
	},
})

This is what I get when I render the mail:

<a href="#ZgotmplZ" class="button" style="display:inline-block;border-radius:3px;font-size:15px;line-height:45px;text-align:center;text-decoration:none;-webkit-text-size-adjust:none;mso-hide:all;color:#ffffff;background-color:#57cbcc;width:200px" target="_blank" width="200">
Call
</a>

#ZgotmplZ is pretty unexpected. It works well with mailto: links.

I guess Go is treating tel: as unsafe content: https://stackoverflow.com/a/14796642/10385339

@matcornic
Copy link
Owner

Go officially considers tel as unsafe. Only http, https and mailto are supported

See discussions:

And documentation:

@sklinkert
Copy link
Author

Hmm I'm not really sure if a programming language should forbid things like this. I mean it's a tool. No more, no less. I think at the end it's up to the OS (if it's supporting phone calls) to decide if a phone number is evil and if it should block it or at least warn the user etc.

@DavidKittleSEL
Copy link

Hmm I'm not really sure if a programming language should forbid things like this. I mean it's a tool. No more, no less. I think at the end it's up to the OS (if it's supporting phone calls) to decide if a phone number is evil and if it should block it or at least warn the user etc.

Couldn't agree with you more. I am having the same problem with "file://" links. In the interim I have a simple workaround that seems to be working quite well.

fileLink := "file://server/share/folder/"
replaceMe := "https://replacethislink"

// Generate the email
h := hermes.Hermes{
	Product: hermes.Product{
		Name: "Awesome Email",
		Logo: "http://www.duchess-france.org/wp-content/uploads/2016/01/gopher.png",
	},
}

email := hermes.Email{
	Body: hermes.Body{
		Name: user,
		Intros: []string{
			"Interesting Title",
		},
		Actions: []hermes.Action{
			{
				Instructions: "Check out this working file:// link",
				Button: hermes.Button{
					Text: "File Link",
					Link: replaceMe,
				},
			},
		},
		Outros: []string{
			"Need help, or have questions? Just reply to this email, we'd love to help.",
		},
	},
}

emailBody, err := h.GenerateHTML(email)
if err != nil {
	fmt.Printf("Error while trying to generate email: %v", err)
}

emailBody = strings.ReplaceAll(emailBody, replaceMe, fileLink)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants