YouTube titles with single quote(s) causes topic title to get cut off

To reproduce:

  1. Paste YouTube link with title containing single quote in new topic title field
    Example link: https://www.youtube.com/watch?v=L6EbORDmpNY
    YouTube Title: Colin Wolfe & ‘The Chronic’

  2. Fetched title cuts off at the first appearance of single quote.
    Discourse Title: Colin Wolfe &

In the source of that YouTube page, the title that Discourse is retrieving looks like this:

document.title = "Colin Wolfe \u0026 'The Chronic' - YouTube";

I’m guessing that the quote throws it off somewhere in here:
https://github.com/discourse/discourse/blob/beta/lib/retrieve_title.rb#L18-L33

4 Likes

I can’t repro this locally or on try. But as a precautionary measure we will now sanitize YouTube video title as per:

https://github.com/discourse/onebox/commit/e6a958bc78eb46c05f850f85adb1e9a9be4a9b0e

5 Likes

Are you pasting it in the Topic title field? I just tried it here and was able to reproduce.

4 Likes

Ah, I missed that. Will repro and fix next week.

5 Likes

Fixed via:

https://github.com/discourse/onebox/commit/52ba73fd53c06157ccd3d17dfd9c91ecb56a8fa3

Thanks for reporting this issue @cmwebdev :+1:

6 Likes

This topic was automatically closed after 6 hours. New replies are no longer allowed.