8
0
فهرست منبع

Other: Prevented from adding markers with names containing "," character.

Szymon Cofalik 5 سال پیش
والد
کامیت
992f967d43
2فایلهای تغییر یافته به همراه11 افزوده شده و 0 حذف شده
  1. 5 0
      packages/ckeditor5-engine/src/model/markercollection.js
  2. 6 0
      packages/ckeditor5-engine/tests/model/markercollection.js

+ 5 - 0
packages/ckeditor5-engine/src/model/markercollection.js

@@ -92,6 +92,11 @@ export default class MarkerCollection {
 	 */
 	 */
 	_set( markerOrName, range, managedUsingOperations = false, affectsData = false ) {
 	_set( markerOrName, range, managedUsingOperations = false, affectsData = false ) {
 		const markerName = markerOrName instanceof Marker ? markerOrName.name : markerOrName;
 		const markerName = markerOrName instanceof Marker ? markerOrName.name : markerOrName;
+
+		if ( markerName.includes( ',' ) ) {
+			throw new CKEditorError( 'markercollection-incorrect-marker-name: Marker name cannot contain "," character.', this );
+		}
+
 		const oldMarker = this._markers.get( markerName );
 		const oldMarker = this._markers.get( markerName );
 
 
 		if ( oldMarker ) {
 		if ( oldMarker ) {

+ 6 - 0
packages/ckeditor5-engine/tests/model/markercollection.js

@@ -123,6 +123,12 @@ describe( 'MarkerCollection', () => {
 
 
 			expect( marker.getRange().isEqual( range2 ) ).to.be.true;
 			expect( marker.getRange().isEqual( range2 ) ).to.be.true;
 		} );
 		} );
+
+		it( 'should throw if marker name with "," is added', () => {
+			expectToThrowCKEditorError( () => {
+				markers._set( 'foo,bar', range );
+			}, /^markercollection-incorrect-marker-name:/, markers );
+		} );
 	} );
 	} );
 
 
 	describe( 'has', () => {
 	describe( 'has', () => {