• I tested Clink and it seems to be working generally very well. Just one thing seems to be working incorrectly: some characters like the ampersand (&) are encoded in the URLs.

    The target URL we have: https://example.com/?product=shoe&color=yellow

    What we see in the address bar after Clink redirection: https://example.com/?product=shoe& #038;color=yellow (minus the space)

    This happens with both types of redirections, with and without the timer. However, this does not happen if the user clicks the link on the redirection page or if admin clicks the link on the link list at wp-admin/edit.php?post_type=clink.

    The cause of the problem is that the URLs are stored in the database in the _postmeta table in an encoded format, which works correctly when echoing the link in HTML, like the two clickable links mentioned above, but it does not work properly when blindly redirected to.

    Fix

    Edit https://plugins.trac.www.ads-software.com/browser/clink/trunk/clink-template.php and replace current line 13, which is

    $clink_url = get_post_meta($post_id, 'clink_url', true);

    with

      $clink_url_for_html        = get_post_meta($post_id, 'clink_url', true);
      $clink_url_for_redirection = str_replace('&', '&', $clink_url_for_html);

    (Notice the variable names making it clear which should be used and where.)

    and then replace every current occurrence of $clink_url with $clink_url_for_html, except on lines
    57, 108 and 127 with $clink_url_for_redirection. Also declare $clink_url_for_redirection as global inside clink_page_generator(), after line 31.

    This fix does not decode the single quote (‘) encoded in the URLs, but can be easily extended to do so if necessary by adding another str_replace() call.

    Code cleanup

    Lines 85 and 110 in https://plugins.trac.www.ads-software.com/browser/clink/trunk/clink-template.php are redundant and can be deleted to make the code easier to read and work with.

    • This topic was modified 8 years, 2 months ago by Daedalon.
    • This topic was modified 8 years, 2 months ago by Daedalon. Reason: WP.org forums show "& #038;" (minus the space) incorrectly as "&"
Viewing 1 replies (of 1 total)
  • Thread Starter Daedalon

    (@daedalon)

    The example of the wrong link is still shown wrong. Not sure if www.ads-software.com forum allows to write it accurately at all, and now it doesn’t allow editing the post anymore. The problem is that the single ampersand (&) has become six characters: ampersand, hash (#), numbers zero, three and eight and a semicolon (038;). I’ll try writing them under each other:

    &
    #
    0
    3
    8
    ;

    Let’s see if they show properly now.

Viewing 1 replies (of 1 total)
  • The topic ‘Don’t convert HTML chars’ is closed to new replies.