# Títulos do YouTube com aspas simples fazem o título do tópico ser cortado

**URL:** https://meta.discourse.org/t/youtube-titles-with-single-quote-s-causes-topic-title-to-get-cut-off/90370
**Category:** Bug
**Created:** [Junho 21, 2018, 5:02am UTC](https://meta.discourse.org/t/youtube-titles-with-single-quote-s-causes-topic-title-to-get-cut-off/90370 "2018-06-21T05:02:12Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![cmwebdev](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cmwebdev/32/122368_2.png) [@cmwebdev](https://meta.discourse.org/u/cmwebdev)
#### Post date: [Junho 21, 2018, 5:02am UTC](https://meta.discourse.org/t/youtube-titles-with-single-quote-s-causes-topic-title-to-get-cut-off/90370/1 "2018-06-21T05:02:12Z")

</div>

**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:

```js
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>

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [Junho 21, 2018, 5:44am UTC](https://meta.discourse.org/t/youtube-titles-with-single-quote-s-causes-topic-title-to-get-cut-off/90370/3 "2018-06-21T05:44:13Z")

</div>

> [@cmwebdev](#):
>
> Fetched title cuts off at the first appearance of single quote.

I can’t repro this locally or on [try](https://try.discourse.org/t/what-is-a-onebox/276/12?u=rudy). But as a precautionary measure we will now sanitize YouTube video title as per:

[https://github.com/discourse/onebox/commit/e6a958bc78eb46c05f850f85adb1e9a9be4a9b0e](https://github.com/discourse/onebox/commit/e6a958bc78eb46c05f850f85adb1e9a9be4a9b0e)

---

<div class="post-metadata">

### Author: ![cmwebdev](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cmwebdev/32/122368_2.png) [@cmwebdev](https://meta.discourse.org/u/cmwebdev)
#### Post date: [Junho 21, 2018, 1:55pm UTC](https://meta.discourse.org/t/youtube-titles-with-single-quote-s-causes-topic-title-to-get-cut-off/90370/4 "2018-06-21T13:55:02Z")

</div>

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

 ![image](https://global.discourse-cdn.com/meta/original/3X/d/4/d46cba435ced2153e7b1f207fd7b4a0f2b0fa542.jpg)

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [Junho 22, 2018, 5:29pm UTC](https://meta.discourse.org/t/youtube-titles-with-single-quote-s-causes-topic-title-to-get-cut-off/90370/5 "2018-06-22T17:29:43Z")

</div>

> [@cmwebdev](#):
>
> Are you pasting it in the Topic title field?

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

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [Junho 25, 2018, 5:39am UTC](https://meta.discourse.org/t/youtube-titles-with-single-quote-s-causes-topic-title-to-get-cut-off/90370/6 "2018-06-25T05:39:13Z")

</div>

Fixed via:

[https://github.com/discourse/onebox/commit/52ba73fd53c06157ccd3d17dfd9c91ecb56a8fa3](https://github.com/discourse/onebox/commit/52ba73fd53c06157ccd3d17dfd9c91ecb56a8fa3)

Thanks for reporting this issue @cmwebdev 👍

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [Junho 25, 2018, 12:30pm UTC](https://meta.discourse.org/t/youtube-titles-with-single-quote-s-causes-topic-title-to-get-cut-off/90370/7 "2018-06-25T12:30:03Z")

</div>

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