Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#32214 closed defect (bug) (duplicate)

Video subtitles removed from shortcode

Reported by: starepod's profile starepod Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.2
Component: TinyMCE Keywords: needs-patch
Focuses: javascript Cc:

Description (last modified by SergeyBiryukov)

I think a previously fixed bug, #29826 has re-appeared. Subtitle information added to a video loaded from the Media Library is being stripped from the [video] shortcode when a post is saved, or when toggling from Visual to Text mode and back.

I'm running WP 4.2.1, logged in as an admin, using the up-to-date Twenty Fifteen theme, and no plugins are active.

If you insert the video, edit the video, add subtitles, click the Update button in the modal (save the update not the post) the preview shows the [cc] button for subtitles. If you switch to Text mode before saving the post you can see that the <track> tag is added, and that the angle brackets are HTML entities, which immediately get stripped out when switching back to Visual mode.

Attachments (1)

32214.patch (3.5 KB) - added by scriptrunner 10 years ago.

Download all attachments as: .zip

Change History (10)

#1 @SergeyBiryukov
10 years ago

  • Description modified (diff)

This ticket was mentioned in Slack in #core by iseulde. View the logs.


10 years ago

#3 @iseulde
10 years ago

  • Component changed from Media to TinyMCE
  • Focuses javascript added
  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 4.2.3
  • Version changed from 4.2.1 to 4.2

#5 @iseulde
10 years ago

Thanks for the report @starepod!

@scriptrunner
10 years ago

#6 @scriptrunner
10 years ago

It looks like HTML5 and Shortcodes were being mixed together. As reported by @starepod, after adding subtitles, the editor showed something like this:

[video width="480" height="360" mp4="http://localhost/wp-content/uploads/2015/06/test.mp4"]&gt; srclang="en" label="English" kind="subtitles" src="http://localhost/wp-content/uploads/2015/06/test.vtt"&lt;[/video]

which is putting the nested track tag as HTML5 inside the partent video tag as a shortcode. So my first update was to change the output to:

[video width="480" height="360" mp4="http://localhost/wp-content/uploads/2015/06/test.mp4"][track srclang="en" label="English" kind="subtitles" src="http://localhost/wp-content/uploads/2015/06/test.vtt"][/track][/video]

This presented two more issues, one which I've also added to the patch, the other I haven't solved yet.

1) There was no track shortcode, so I added that, primarily using code from the original plugin.

2) Once you save the page/post, then you can't edit the video again, as it's throwing a JavaScript error in jQuery:

`jquery....=1.11.2 (line 2, col 12716)
Error: Syntax error, unrecognized expression: [track srclang="en" label="English" kind="subtitles" src="http://localhost/wp-content/uploads/2015/06/test.vtt"][/track]

....value:null},gb.error=function(a){throw new Error("Syntax error, unrecognized ex...`

This one seems tricky and I haven't found a solution yet. I'm pretty sure it has to do with the wp_ajax_parse_media_shortcode() function in wp-admin/includes/ajax-actions.php

I'll continue working on it, but perhaps someone more knowledgeable with core can figure it out quicker. This is my first patch, so I hope a partial one to get he ball rolling is ok. I also rely heavily on closed captioning, so this ticket is dear to me :)

#7 follow-up: @azaozz
10 years ago

Thinking this is a duplicate of #32078. The <track> tag disappears as it is "legal" only in a <video> or <audio>. We insert markers which are paragraphs with the actual shortcode, so the <track> tags become children of <p> and are removed.

@scriptrunner can you check if [32678] fixes it for you.

#8 in reply to: ↑ 7 ; follow-up: @scriptrunner
10 years ago

Yes, just verified that [32678] fixes the issue. Thank you! Didn't see the duplicate ticket.

Replying to azaozz:

Thinking this is a duplicate of #32078. The <track> tag disappears as it is "legal" only in a <video> or <audio>. We insert markers which are paragraphs with the actual shortcode, so the <track> tags become children of <p> and are removed.

@scriptrunner can you check if [32678] fixes it for you.

#9 in reply to: ↑ 8 @azaozz
10 years ago

  • Milestone 4.2.3 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #32078.

Replying to scriptrunner:

Great, thanks.

Note: See TracTickets for help on using tickets.