Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Spaces in URLS

Participant ,
Dec 30, 2008 Dec 30, 2008
When users on my site submit a report, an email is generated with cfmail that passes the URL where the report can be found.

On some of the URL strings there are spaces and the link within the mail is not accurate. It dies at the space...

Should I use URLEncodedFormat to solve this issue? I can't have any spaces in the URL or else it won't work correctly.
1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 30, 2008 Dec 30, 2008
I would just make sure the cfmail has a type=html and i would wrap the url in a <a> tag. The browser will take care of the encoding.

<cfset urltest = " http://www.google.com?test=test test">
<cfmail to="email@email.com" from="email@email.com" subject="testing" type="html">
<a href="#urltest#">#urltest#</a>
</cfmail>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 30, 2008 Dec 30, 2008
That's a good idea... but many of the site users are old school and may not have html enabled email...
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 30, 2008 Dec 30, 2008
Ok, since you're not wrapping in html format your sending as a plain text. So in your case the urlencodedformat won't be an option as it will just return a encoded format like (ie. ttp%3A%2F%2Fwww%2Egoogle%2Ecom%3Ftest%3Dtest%20test http://www.google.com?test=test%20test ) which won't do much for your receipient. So i would just do a replace on the space with %20 and that should work for html and plain text format.
<cfset urltest = " http://www.google.com?test=test test">
<cfset urltest = replace(urltest,' ','%20','all')>
This should return in the email
http://www.google.com?test=test%20test
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 30, 2008 Dec 30, 2008
Since you can't use HTML formatted emails, then you're initial assumption is correct. URLEncodedFormat() will properly convert spaces and other pesky URL characters so that any browser should properly handle the URL request.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 30, 2008 Dec 30, 2008
LATEST
How are the spaces getting there to start with?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources