Skip to content

Whitespace not stripped from link preview card titles #29993

@daprice

Description

@daprice

Steps to reproduce the problem

  1. View the post https://mastodon.social/@gvwilson/112294375846907813 and look at the title of the link preview card.

Expected behaviour

Title should begin with text, not excessive whitespace

Actual behaviour

Title contains excessive whitespace before the text

Detailed description

The site this post links to has an… interesting way of marking up their title tags:
image

While that is ultimately that site’s fault, Mastodon should probably strip the whitespace when parsing it for link previews. It doesn’t, so the result in the web UI is:
image

The string returned for the card by the Mastodon API (https://mastodon.social/api/v1/statuses/112294375846907813) is even worse:
"title": "\r\n\t\t\r\n\t\t\r\n\t\t\t\r\n\t\t\t\r\n\t\t\r\n\t\tLab Dynamics: Management and Leadership Skills for Scientists, Third Edition\r\n\t"

For comparison, it seems web browsers do strip the whitespace when displaying page titles.
image

Mastodon instance

mastodon.social

Mastodon version

v4.3.0-nightly.2024-04-18

Technical details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstatus/confirmedThis bug has been confirmed

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions