CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMail (Moderator: Piotr Szotkowski) »
  • php urlencode seems not to work with CiviMail
Pages: [1]

Author Topic: php urlencode seems not to work with CiviMail  (Read 1640 times)

netvigator

  • I’m new here
  • *
  • Posts: 26
  • Karma: 2
php urlencode seems not to work with CiviMail
January 21, 2015, 07:46:48 am
Another subject for this question could be: does CiviMail unencode URL's that have been encoded with php's urlencode function?

The problem is that in the emails received, some critical characters are not encoded.

I logged into a shell, and used the php interactive shell to test the output of the urlencode function. In the php interactive shell, the urlencode function works OK. So the problem does not seem to be php. But after php encodes the URL, the email arrives with critical characters un-encoded.

We want to send a link to a google form with some fields pre-filled with the contacts info. So contact info is in the link. For best results, the contact info should be url encoded.

So in the email body, there is some php code as follows:

Code: [Select]
<?php
$email 
= '{contact.email}' ;
$phone = '{contact.phone}' ;
$addre = '{contact.street_address}' ;
$addr1 = '{contact.supplemental_address_1}' ;
$addr2 = '{contact.supplemental_address_2}' ;
echo 
'"', 
'https://docs.google.com/forms/d/1Z2HmWNlSGawlWv02eLGKqiFIoR315TqvmULdNiTyAWs/viewform?entry.808868411={contact.contact_id}&entry.522732924={contact.first_name}&entry.1479260442={contact.middle_name}&entry.584749544={contact.last_name}',
'&entry.1102528638=',
urlencode($email),
'&entry.1043154997=',
urlencode($phone),
'&entry.446845703&entry.826383881=',
urlencode($addre),
'&entry.1145565798=',
urlencode($addr1),
'&entry.145943664=',
urlencode($addr2),
'&entry.258308379={contact.city}&entry.1375586439={contact.state_province}&entry.1838089728={contact.postal_code}&entry.1332300293={contact.country}',
'"' ;
?>


The characters that arrive un-encoded are + and %.

The + does not create a big problem, as it is interpreted as a space. We want a + on the front of some phone numbers, the + indicates a country IDD code. We want it, but this glitch does not crash the google form.

As an example of a show stopper, a contact put the % on the left of an address line, as short for c/o care of. The % arrived un-encoded, the un-encoded % crashes the google form.

I logged into a shell, and used the php interactive shell to test the output of the urlencode function. In the php interactive shell, the urlencode function works OK. So the problem does not seem to be php. But after php encodes the URL, the email arrives with the % un-encoded.

If the problem was the internet, urlencode would be problematical for everyone, and the internet surely would have been fixed by now.

I wonder whether CiviMail is un-encoding the URL before it gets sent out!

Assistance would be appreciated!

netvigator

  • I’m new here
  • *
  • Posts: 26
  • Karma: 2
Re: php urlencode seems not to work with CiviMail
January 21, 2015, 08:40:52 am
We are using CiviCRM 4.1.5

Dennis Gray

  • Ask me questions
  • ****
  • Posts: 472
  • Karma: 1
  • CiviCRM version: Various. See post.
  • CMS version: Drupal, Wordpress and Joomla. See post.
  • MySQL version: TBA
  • PHP version: TBA
Re: php urlencode seems not to work with CiviMail
January 21, 2015, 07:17:35 pm
I am in the same organization as the poster. One of our other people suggested this:
Quote
This kinda sounds like some funky interaction between the MIME encoding ( for the e-mail message ) and the urlencoding functions. Especially as it happens around an "=" ( which is both the encoding delimiter and the soft line break in MIME encoding ) and a percent sign ( which is the encoding delimiter for url encoding ).

netvigator

  • I’m new here
  • *
  • Posts: 26
  • Karma: 2
Re: php urlencode seems not to work with CiviMail
January 24, 2015, 07:37:37 am
We have found no problem with urlencode and MIME encoding -- we have successfully sent urlencoded links with problem characters using other mail clients. The links arrive encoded, and they do not crash the google form. This seems to be uniquely a CiviMail problem/defect.

Dennis Gray

  • Ask me questions
  • ****
  • Posts: 472
  • Karma: 1
  • CiviCRM version: Various. See post.
  • CMS version: Drupal, Wordpress and Joomla. See post.
  • MySQL version: TBA
  • PHP version: TBA
Re: php urlencode seems not to work with CiviMail
January 25, 2015, 10:11:53 pm
Please attach the code used to confirm this.

netvigator

  • I’m new here
  • *
  • Posts: 26
  • Karma: 2
Re: php urlencode seems not to work with CiviMail
February 11, 2015, 12:42:53 am
Code to confirm this is in the original post.

netvigator

  • I’m new here
  • *
  • Posts: 26
  • Karma: 2
Re: php urlencode seems not to work with CiviMail
February 11, 2015, 12:45:55 am
Bug posted:

https://issues.civicrm.org/jira/browse/CRM-15953

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviMail (Moderator: Piotr Szotkowski) »
  • php urlencode seems not to work with CiviMail

This forum was archived on 2017-11-26.