Skip to content

Commit 0948a5b

Browse files
committed
Merge branch 't/10224' into major
2 parents 8371034 + dea1c6c commit 0948a5b

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

core/filter.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,7 @@
12341234
styles = element.styles,
12351235
origClasses = attrs[ 'class' ],
12361236
origStyles = attrs.style,
1237-
name,
1237+
name, origName,
12381238
stylesArr = [],
12391239
classesArr = [],
12401240
internalAttr = /^data-cke-/,
@@ -1248,10 +1248,22 @@
12481248
// We can safely remove class and styles attributes because they will be serialized later.
12491249
for ( name in attrs ) {
12501250
// If not valid and not internal attribute delete it.
1251-
if ( !validAttrs[ name ] && !internalAttr.test( name ) ) {
1252-
delete attrs[ name ];
1253-
isModified = true;
1251+
if ( !validAttrs[ name ] ) {
1252+
// Allow all internal attibutes...
1253+
if ( internalAttr.test( name ) ) {
1254+
// ... unless this is a saved attribute and the original one isn't allowed.
1255+
if ( name != ( origName = name.replace( /^data-cke-saved-/, '' ) ) &&
1256+
!validAttrs[ origName ]
1257+
) {
1258+
delete attrs[ name ];
1259+
isModified = true;
1260+
}
1261+
} else {
1262+
delete attrs[ name ];
1263+
isModified = true;
1264+
}
12541265
}
1266+
12551267
}
12561268
}
12571269

@@ -1290,10 +1302,8 @@
12901302

12911303
switch ( element.name ) {
12921304
case 'a':
1293-
attrs = element.attributes;
1294-
if ( !attrs.href && !attrs.name )
1295-
return false;
1296-
if ( !attrs.name && !element.children.length )
1305+
// Code borrowed from htmlDataProcessor, so ACF does the same clean up.
1306+
if ( !( element.children.length || element.attributes.name ) )
12971307
return false;
12981308
break;
12991309
case 'img':

0 commit comments

Comments
 (0)