Best way to urlencode a placeholder?

First, thank you to the developers for a continuous stream of improvements this year!

What would be the best approach to urtencode placeholders I want to use as query parameters? e.g. url?firstname=[FIRSTNAME]
where FIRSTNAME may be a first and middle name with a space between them, for example.

I’m thinking I should just be able to urlencode() or rawurlencode() in the right place, but after seeing another message or two in the forum I think this could mess up link tracking if done wrong?

I don’t think link tracking is useful in such a case anyway, because each link will vary as the placeholder changes. or does the link tracking discard any parameters?

Hmm. Now I’m trying to think why phpList shouldn’t urlencode every link anyway.

Wouldn’t encoded links be universal, but unencoded links possibly break, as in my example?

Thanks for your suggestions.

1 Like

@Brett there are a few problems with this.

phplist currently replaces placeholders without regard to the context such as within a URL inside a href parameter, as text within an html format message, or as text within a plain-text message. See file admin/sendemaillib.php

if (is_array($user_att_values)) {
    // CUT 3
    $htmlmessage = parsePlaceHolders($htmlmessage, $user_att_values);
    $textmessage = parsePlaceHolders($textmessage, $user_att_values);

Then, as you alluded to, using a user attribute within a URL with click tracking enabled will lead to a unique URL for each subscriber. phplist removes only the uid parameter then treats the resultant URL as a unique URL for tracking.


Thank you for this explanation and pointer. It’s a helpful starting point for knowing where to start (for now, a brutal hack :wink: )

And thanks for all your ongoing work on phpList! For my small jazz news publication, phpList is useful for our weekly newsletter because we are committed to respecting the privacy of our readers. It helps us keep the data in country, in our organization, and away from large, evil multi-national surveillance captialists.

There a patch or two I’ve been meaning to submit. Your reply has prompted me to finally get around to this!



1 Like