mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-16 19:46:21 +00:00
TinyMCE: Verify HTML in captions. props azaozz
Built from https://develop.svn.wordpress.org/trunk@30435 git-svn-id: http://core.svn.wordpress.org/trunk@30430 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
fce07e17eb
commit
87023d64b4
@ -1,13 +1,13 @@
|
||||
/* global tinymce */
|
||||
tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||
var DOM = tinymce.DOM,
|
||||
var tb, serializer,
|
||||
DOM = tinymce.DOM,
|
||||
settings = editor.settings,
|
||||
Factory = tinymce.ui.Factory,
|
||||
each = tinymce.each,
|
||||
iOS = tinymce.Env.iOS,
|
||||
toolbarIsHidden = true,
|
||||
editorWrapParent = tinymce.$( '#postdivrich' ),
|
||||
tb;
|
||||
editorWrapParent = tinymce.$( '#postdivrich' );
|
||||
|
||||
function isPlaceholder( node ) {
|
||||
return !! ( editor.dom.getAttrib( node, 'data-mce-placeholder' ) || editor.dom.getAttrib( node, 'data-mce-object' ) );
|
||||
@ -559,6 +559,19 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||
return node && !! ( node.textContent || node.innerText );
|
||||
}
|
||||
|
||||
// Verify HTML in captions
|
||||
function verifyHTML( caption ) {
|
||||
if ( ! caption || ( caption.indexOf( '<' ) === -1 && caption.indexOf( '>' ) === -1 ) ) {
|
||||
return caption;
|
||||
}
|
||||
|
||||
if ( ! serializer ) {
|
||||
serializer = new tinymce.html.Serializer( {}, editor.schema );
|
||||
}
|
||||
|
||||
return serializer.serialize( editor.parser.parse( caption, { forced_root_block: false } ) );
|
||||
}
|
||||
|
||||
function updateImage( imageNode, imageData ) {
|
||||
var classes, className, node, html, parent, wrap, linkNode,
|
||||
captionNode, dd, dl, id, attrs, linkAttrs, width, height, align,
|
||||
@ -636,6 +649,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||
}
|
||||
|
||||
if ( imageData.caption ) {
|
||||
imageData.caption = verifyHTML( imageData.caption );
|
||||
|
||||
id = imageData.attachment_id ? 'attachment_' + imageData.attachment_id : null;
|
||||
align = 'align' + ( imageData.align || 'none' );
|
||||
@ -858,6 +872,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
|
||||
|
||||
// Convert remaining line breaks to <br>
|
||||
caption = caption.replace( /(<br[^>]*>)\s*\n\s*/g, '$1' ).replace( /\s*\n\s*/g, '<br />' );
|
||||
caption = verifyHTML( caption );
|
||||
}
|
||||
|
||||
if ( ! imgNode ) {
|
||||
|
File diff suppressed because one or more lines are too long
Binary file not shown.
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.1-beta1-30430';
|
||||
$wp_version = '4.1-beta1-30435';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
x
Reference in New Issue
Block a user