cancel
Showing results for 
Search instead for 
Did you mean: 

FormattedText, htmlText href="mailto:" doesn't work

jospoon
Explorer
0 Kudos
2,057

I'm getting a block of msgs from a CMS api to display using FormattedText and they have email links in it.

html tag <a> was mentioned supported in FormattedText. But if tried with href="mailto:jo@gmail.com", the rendered view becomes href="#".

https://sapui5.hana.ondemand.com/test-resources/sap/m/FormattedText.html

Replace it with below:

<a href="mailto: jo@gmail.com">jo@gmail.com</a>

And click update. Now if you inspect the link, you will see it like this:

<a href="#" target="_blank">jo@gmail.com</a>

So HTML mailto link doesn't work in FormattedText. Can someone help guide how to go around with this bug?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

I know I am late, but I also struggled and almost opened an incident when I finally found the solution.

So basically FormattedText only allows https and ftp protocol. If you want mailto, you have to add it to the whitelist.

At the beginning of your controller (or even better your Component.js) import

"sap/base/security/URLWhitelist"

Then early on (I suggest onInit) add your protocol to the whitelist.

URLWhitelist.add("mailto");
jospoon
Explorer
0 Kudos

Works like a charm. Thanks Marc!

Answers (0)