Skip to content

Conversation

timothyjrogers
Copy link
Contributor

Fixes #29993

When link details are extracted any excess whitespace contained in the source HTML title element gets included in the status record. Some browsers then display the card content and/or tooltip with that extraneous whitespace which puts the content out of normal alignment. This change trims off that whitespace prior to rendering, however it does not change the behavior when saving the link details in the status record.

@renchap
Copy link
Member

renchap commented Apr 21, 2024

I think I would prefer this to be done when extracting the data rather than on display time, mostly for consistency across the various clients.

Would there be any downsides to doing it this way?

@timothyjrogers
Copy link
Contributor Author

timothyjrogers commented Apr 21, 2024

@renchap I don't think there is a downside to doing it that way, as long as the record doesn't need to be a faithful recreation of the original content. I can't think of a scenario where you would do anything with that retained whitespace (other than trim it off). Plus then the instance doesn't have to carry around those extra bytes.

If there are no objections I'll update this and instead make the change in the extraction code.

@timothyjrogers
Copy link
Contributor Author

I've reverted the change to how card renders and instead trimmed the offending whitespace when link_details_extractor first fetches the title. The only downside to this is that previously fetched link titles will still have any extraneous whitespace, but given this only happens when a site has a weirdly formatted <title> tag I can't imagine that is super prevalent.

Copy link
Contributor

@ClearlyClaire ClearlyClaire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

Whether the stripping is done at extraction or display is currently unimportant. It could become important when we go forward with our plan to federate preview card data, but we can re-evaluate at that point.

@ClearlyClaire ClearlyClaire added this pull request to the merge queue Apr 24, 2024
Merged via the queue into mastodon:main with commit b128474 Apr 24, 2024
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

Successfully merging this pull request may close these issues.

Whitespace not stripped from link preview card titles
3 participants