Issue using user-mail with hyphen in linkto tag

Hi,

We are facing some issues with URLs that are generated within a capture tag using user e-mail addresses having a hyphen in it.

This is a code example of what we want to achieve:
User e-mail: {{ user.email }}
User name: {{ user.name }}

{% capture linkToUploadProxy %}http://xxxxx.ey.net:9999/export/corporatetax/pdf?useremail={{ user.email }}{% endcapture %}

{{ linkToUploadProxy }} <br>

{% linkto linkToUploadProxy target:"_blank" %}Link{% endlinkto %}

When the user has an e-mail address without hyphen everything works fine. However, when the user has a hyphen in their e-mail address, we get following liquid error:

Liquid error: URI must be ascii only"http://xxxxx.ey.net:9999/export/corporatetax/pdf?useremail=name.surname1 \u2010 surname2@be.ey.com" in code: linkto linkToUploadProxy target:"_blank"

We can see the hyphen is translated into \u2010 . However, when I display the capture tag, that issue does not appear there. It is only within the linkto tag.

Please also find hereunder a screenshot showing our issue:

Is this a bug or do you have a workaround?

Thanks in advance.

Kind regards,
Gianluca

Hi Gianluca,

You could use the filter “url_encode” which will handle all this potential issues and generate a safe string to be used as a link.

So, implemented in your code would look like this:

{% capture linkToUploadProxy %}http://xxxxx.ey.net:9999/export/corporatetax/pdf?useremail={{ user.email | url_encode }}{% endcapture %}

{{ linkToUploadProxy }} <br>

{% linkto linkToUploadProxy target:"_blank" %}Link{% endlinkto %}

I hope this solves your issue.
Kind regards,
Agustín

1 Like

Hi Agustin,

Thanks for your quick reply. This fixed it!

Kind regards,
Gianluca

1 Like