mirror of
git://develop.git.wordpress.org/
synced 2025-04-07 13:43:25 +02:00
TinyMCE: strip tags from pasted URLs before testing if they are embeddable.
Props siobhan, iseulde. Fixes #31158. git-svn-id: https://develop.svn.wordpress.org/trunk@31817 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f288ec0581
commit
25a5f07d51
@ -167,9 +167,11 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
||||
// matching view patterns, and transform the matches into
|
||||
// view wrappers.
|
||||
editor.on( 'BeforeSetContent', function( event ) {
|
||||
var node;
|
||||
var pastedStr = event.content,
|
||||
trim = tinymce.trim,
|
||||
node;
|
||||
|
||||
if ( ! event.content ) {
|
||||
if ( ! pastedStr ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -179,10 +181,22 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
||||
|
||||
node = editor.selection.getNode();
|
||||
|
||||
pastedStr = pastedStr.replace( /<[^>]+>/g, '' );
|
||||
pastedStr = trim( pastedStr );
|
||||
|
||||
// When a url is pasted, only try to embed it when pasted in an empty paragrapgh.
|
||||
if ( event.content.match( /^\s*(https?:\/\/[^\s"]+)\s*$/i ) &&
|
||||
( node.nodeName !== 'P' || node.parentNode !== editor.getBody() || ! editor.dom.isEmpty( node ) ) ) {
|
||||
return;
|
||||
if ( /^https?:\/\/\S+$/i.test( pastedStr ) ) {
|
||||
event.content = pastedStr;
|
||||
|
||||
node = editor.dom.getParent( node, function( node ) {
|
||||
if ( node.parentNode === editor.getBody() ) {
|
||||
return node;
|
||||
}
|
||||
} );
|
||||
|
||||
if ( node.nodeName !== 'P' || trim( node.textContent ) || trim( node.innerText ) ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
event.content = wp.mce.views.setMarkers( event.content );
|
||||
|
Loading…
x
Reference in New Issue
Block a user