Project

General

Profile

Actions

Bug #21929

closed

Header image keeps disappearing

Added by Laurie Hurson 4 days ago. Updated 4 days ago.

Status:
Resolved
Priority name:
Normal
Assignee:
-
Category name:
S3 Uploads
Target version:
Start date:
2025-01-29
Due date:
% Done:

0%

Estimated time:
Deployment actions:

Description

Hi All,

A user's header image on the course site below keeps disappearing. She has reset it and I have reset it multiple times. I have asked her to clear her cookies and cache and, even once reset, it disappearing again in a matter of hours.

Once reset, it may appear for several hours but in a matter of time, it disappears. I can confirm that last time it was successfully reset by me was yesterday at 11:15am, she said she could see it in class (time unsure) but this morning it was gone.

This is happening across chrome, safari, and firefox (in private/incognito mode).

Course site: https://espeeuu.commons.gc.cuny.edu/


Files

Image_1-29-25_at_9.37_AM.jpeg (758 KB) Image_1-29-25_at_9.37_AM.jpeg Laurie Hurson, 2025-01-29 11:10 AM
Actions #1

Updated by Boone Gorges 4 days ago

  • Category name set to S3 Uploads
  • Target version set to 2.5.2

The image isn't really "disappearing". Because this is a private site, the image has a URL with an expiring signature. We filter post content to ensure that image URL signatures are swapped out, but it hasn't yet been implemented for header images. (This part of the long tail of S3-related issues I discussed on yesterday's dev call.) I'll put a fix into place. For the moment, please don't change the image on that site, so that I can use it as a test.

Actions #2

Updated by Laurie Hurson 4 days ago

Right,not disappearing- thanks for the clarification.

Wont touch anything on the site for now. And ill tell the user know you are taking a look so hopefully they don't make any changes either.

Actions #3

Updated by Laurie Hurson 4 days ago

We just got another similar report to the help desk

https://cl89200sp25.commons.gc.cuny.edu/

User writes:

It's running on the Ashe theme, and initially, the header image I chose displayed with no issues. Yesterday, >however, I noticed that the header was no longer visible, and when I tried trouble-shooting, I found that I >couldn't get any image to display in the header.

Actions #4

Updated by Boone Gorges 4 days ago

I've put a general fix in place in https://github.com/cuny-academic-commons/cac/commit/85f10ffcbceedb85a99af03486faf124cd4714b4, which is pushed to the production site. This fixes the problem for https://espeeuu.commons.gc.cuny.edu/ and probably most other sites.

The Ashe theme is doing something strange, which I'm now investigating.

Actions #5

Updated by Laurie Hurson 4 days ago

Thanks for the fix and further investigation!

Actions #6

Updated by Boone Gorges 4 days ago

The problem with Ashe is that it shows the header image not using a 'src' attribute, but by printing a background-image CSS declaration to the page. The Ashe theme uses esc_url() when printing the CSS, which in general is a pretty good practice. But esc_url() encodes query arg characters like ampersands in such a way that CSS is unable to understand them. Therefore, the signature param is not included with the S3 request, and the user gets a 403.

If Ashe were abandoned, I'd put a hotfix in place. But it appears to be maintained, so I need some sort of persistent fix. The call to esc_url() is hardcoded into the ashe_dynamic_css() method, and there's no easy way to intercept that markup before it's echoed. So the technique I chose is as follows: add a callback to the 'clean_url' filter (inside of esc_url()); detect whether the caller is ashe_dynamic_css(); and if so, use esc_url_raw() plus some additional XSS mitigations. A general 'clean_url' callback would run far, far too often, so I try to target it by (a) only adding the filter at 'wp_head' if we determine that the current theme is running Ashe (and then unhooking it afterward), and (b) by checking the debug_backtrace() to ensure we're looking at the right caller. This method is totally bonkers, and perhaps in retrospect I should have unhooked 'ashe_dynamic_css' from 'wp_head', dumped it into an output buffer, and then done a search-replace on it. But I'm going to stick with this for now, since it's built and it's working: https://github.com/cuny-academic-commons/cac/commit/fe3813c76e618a7846ef9be3a7b4bc9f28c6e708

Copying Jeremy and Ray here so you're aware of the hoops we're jumping through. It's nearly certain that other themes are using PHP to generate background-image CSS using S3-stored files, and if they also use esc_url, then we will run into the same issue.

Laurie, if you're able to confirm that the images are working properly, I'll close this one out.

Actions #7

Updated by Laurie Hurson 4 days ago

I can see now see the images on both course sites.

tested an image on another site ashe theme here too: https://yourname.commons.gc.cuny.edu/

All looks good to me. Thanks Boone!

Actions #8

Updated by Boone Gorges 4 days ago

  • Status changed from New to Resolved

Thanks for confirming!

Actions

Also available in: Atom PDF