Q_Response::setMeta(): clear stale og:image companion tags when a later image can't be sized - #39
Open
zattak1 wants to merge 1 commit into
Open
Q_Response::setMeta(): clear stale og:image companion tags when a later image can't be sized#39zattak1 wants to merge 1 commit into
zattak1 wants to merge 1 commit into
Conversation
…e sized setMeta() keys metas by "name:value", so a second og:image REPLACES the first. The four companion tags it derives -- og:image:width, :height, :secure_url, :type -- were only ever written, never cleared, and only written when getimagesize() succeeded. So a page that set a sizeable og:image first (the app default, on local disk) and an unsizeable one second (a stream icon that is missing, or remote) ended up advertising a set that described the image that LOST: og:image:secure_url pointed at the default while og:image pointed at the icon, and the declared width/height/type matched neither. Unfurlers that prefer secure_url therefore showed a different image from the one og:image names -- which is how conversation permalinks came to show the app logo rather than nothing at all while their og:image 404ed (ro#388). og:image is well-formed on its own, so clear the stale set rather than leave it describing another image. Adds Q_Response::clearMeta() to remove metas by key from both the global set and every slot. Refs ro#388
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A page that sets
og:imagetwice can end up advertising companion tags that describe the image that lost.Cause
setMeta()derives four companions whenever anog:imageis set andgetimagesize()succeeds:og:imageitself is stored asself::$metas[$key]keyed byname:value, so a second call replaces the first. The four companions are only ever written, never cleared — and only written when the size lookup succeeds.So when a page sets a sizeable
og:imagefirst (an app default on local disk) and an unsizeable one second (a stream icon that is missing, or a remote URL), the survivors are the first image's:og:image:secure_urlnames a different image fromog:image, and the declared 400×400 /image/pngdescribes neither. Unfurlers that prefersecure_urlshow the wrong image entirely; the rest advertise wrong dimensions.Fix
og:imageis well-formed on its own, so clear the stale set rather than leave it describing another image. AddsQ_Response::clearMeta(), which removes metas by key from both the global set and every slot.Verified against a live install: with a correctly sized image the companions are rewritten as before (
1000/1000/image/jpeg,secure_url==og:image); with an unsizeable one they are now absent rather than stale.