Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.
https://jetpack.com/
Other
1.59k stars 798 forks source link

Relative links broken in subscription emails if WP site is in subdirectory #18069

Open sfarbota opened 3 years ago

sfarbota commented 3 years ago

Steps to reproduce the issue

  1. Set WordPress home directory to https://www.mysite.com/blog/ (So all paths within WP are relative to /blog)
  2. Subscribe to blog with Jetpack plugin
  3. Create a new blog post with relative links like /my-page.html

What I expected

Email sent out to subscribers should have https://mysite.com/my-page.html as the link URL. This is how browsers interpret the link and is the W3C standard.

What happened instead

Email sent out to subscribers has https://mysite.com/blog/my-page.html as the link URL (including subdirectory /blog). This is breaking links in our emails, forcing us to create redirects for every such relative link we create.

This was working properly in previous versions of the plugin, at least as recently as v8.6.1. We are now on v9.2 and are experiencing this issue.

Note: Making the links absolute is not a viable solution for us as we are hosting the same blog on several different domains and want the relative links to work accordingly; i.e., if the post is accessed from https://www.mysite.ca/blog, the /my-page.html link will point to https://www.mysite.ca/my-page.html

sfarbota commented 3 years ago

I've looked through the source code and can't find the logic that would handle this. Perhaps it's part of WordPress.com's code?

jeherve commented 3 years ago

Perhaps it's part of WordPress.com's code?

Yes that may be the case, as the emails are sent from WordPress.com.

cc @mdbitz just in case this may be related to sync?

mdbitz commented 3 years ago

@sfarbota Steve, can you share a site and post that this triggered on. It would allow us to quickly review the data in the Cache Site to see if it is an issue in how the data is saved or if it is further in the subscriptions email code in WP.com

sfarbota commented 3 years ago

Thanks for the replies! Here's the post in question: https://www.coleparmer.com/blog/2020/12/09/video-traceable-thermometer-first-covid-19-vaccines/

mdbitz commented 3 years ago

Tested this out in full and the data is synced to the WP.com Cache Site as is. This means that Cache site has the relative link in the content. The Subscription service is modifying the urls to include the sub directly I expect it is use the site_url or home instead of only the domain.

This isn't a change on the Jetpack plugin side but in WP.com.

More investigation needed, I'm tied down this week wrapping up checksums so if some other colleague can investigate further A+ if not will try to squeeze it in.

sfarbota commented 3 years ago

Thanks for looking into this, @mdbitz ! I'd be happy to open a separate ticket in the WP Trac site if you think that would be more appropriate.

jeherve commented 3 years ago

I'd be happy to open a separate ticket in the WP Trac site if you think that would be more appropriate.

Here is perfect, thank you. We'll update this issue as we make progress on the problem.

sfarbota commented 3 years ago

Hello again @jeherve and @mdbitz - I hate to be a pest, but I'm wondering if you might be able to offer any approximate ETA on when this might be resolved. We have a temporary workaround process in place, but it's not ideal and adds extra time to the publishing/editing/testing process for each post.

jeherve commented 3 years ago

I'm wondering if you might be able to offer any approximate ETA on when this might be resolved

I'm afraid we do not have an ETA yet. We're not currently iterating on the Subscriptions feature, and since this issue impacts a very low number of folks (the use of relative links is not quite common with WordPress, especially combined with a site living in a subdirectory), we have not prioritized this issue yet. We will update this issue once we start working on this.

sfarbota commented 3 years ago

Ok, understood. I had a feeling that was likely the case. Thanks for the reply though - knowing that this may take a while to address at least helps us plan things out a bit better.