I've got a url in my newsletter:
http://www.example.com/smartsite.dws?ch=int&id=73822
When sending the email, the following page is loaded: http://www.purmerend.nl/smartsite.dws?ch=int

This is because the url is not htmlencoded.

I've changed the following code

function _simplenews_statistics_replace_url($match, $nid, $mail) {
  if (substr($match, 0, 1) == "#")
    return $match;

  require_once drupal_get_path('module', 'simplenews_statistics') .'/rc4.inc';
  $pars = 'nid='. $nid .'&mail='. $mail .'&url='.$match;
  $pars = rc4Encrypt(simplenews_private_key(), $pars);
  $pars_hash = md5($pars);
  
  return url('simplenews/statistics/click', array('absolute' => TRUE, 'query' => array('p' => _simplenews_statistics_encode_parameter($pars), 
                                                                                       'h' => _simplenews_statistics_encode_parameter($pars_hash))));
}

to

function _simplenews_statistics_replace_url($match, $nid, $mail) {
  if (substr($match, 0, 1) == "#")
    return $match;

  require_once drupal_get_path('module', 'simplenews_statistics') .'/rc4.inc';
  $pars = 'nid='. $nid .'&mail='. $mail .'&url='. urlencode($match);
  $pars = rc4Encrypt(simplenews_private_key(), $pars);
  $pars_hash = md5($pars);
  
  return url('simplenews/statistics/click', array('absolute' => TRUE, 'query' => array('p' => _simplenews_statistics_encode_parameter($pars), 
                                                                                       'h' => _simplenews_statistics_encode_parameter($pars_hash))));
}

As you can see, i've added a urlencode on the url. This solved the problem for me. Would be great if this would be added to the next release :)

Comments

Docc’s picture

Assigned: Unassigned » Docc
Status: Active » Needs review

tnx will review when i find the time

weseze’s picture

StatusFileSize
new767 bytes

The problem can also be solved when creating the url for the drupal_goto function in the simplenews_statistics_click() function. I think this would be a better place for a patch, because the full data of the url is stored and in this way the patch is bacwards compatible.
I haven't got much time to write a clean patch, but the one attached works.

luksak’s picture

works for me.

please apply this.

luksak’s picture

StatusFileSize
new758 bytes

your patch had a little error.
here is the fixed patch.

Docc’s picture

Version: 6.x-2.1 » 6.x-3.x-dev
Status: Needs review » Closed (fixed)

Commited to 3.x