Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 4.3.3 Breaks Query Params on Attachments #112

Open
thefrosty opened this issue Apr 1, 2024 · 0 comments
Open

Version 4.3.3 Breaks Query Params on Attachments #112

thefrosty opened this issue Apr 1, 2024 · 0 comments

Comments

@thefrosty
Copy link

Added in #111

$post_image = $image[0];
$filename =  basename($post_image);
$encfilename = urlencode($filename);
$post_image = str_replace($filename, $encfilename, $post_image);

basename of the image URL that contains query params will include these queries.

Example:
Attachment: $image[0] = https://DOMAIN/wp-content/uploads/2024/04/IMG_1000-50x35.jpg?utm_source=sailthru&utm_medium=email

What basename($post_image) returns: IMG_0171-50x35.jpg?utm_source=sailthru&utm_medium=email. Which wouldn't be a problem if you didn't replace the $filename with $encfilename.

The outcome of the new attachment URL that is send to Sailthru is now: https://DOMAIN/wp-content/uploads/2024/04/IMG_1000-50x35.jpg%3Futm_source%3Dsailthru%26utm_medium%3Demail which isn't a valid URL since only the query params are encoded.

Suggested replacement: $filename = basename(parse_url($url, PHP_URL_PATH));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant