From c4f331374cf1acd843555340aee5d83497fb3918 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Smyrek?= Date: Tue, 16 Mar 2021 16:14:15 +0100 Subject: [PATCH] Used utils functions to check numerical value, unified domain matcher, fixed media embed matcher --- packages/ckeditor5-font/src/fontsize/fontsizeediting.js | 5 ++++- packages/ckeditor5-font/tests/fontsize/fontsizeediting.js | 2 +- packages/ckeditor5-link/src/autolink.js | 2 +- packages/ckeditor5-media-embed/src/automediaembed.js | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/ckeditor5-font/src/fontsize/fontsizeediting.js b/packages/ckeditor5-font/src/fontsize/fontsizeediting.js index cd91d98092c..94003b0fde8 100644 --- a/packages/ckeditor5-font/src/fontsize/fontsizeediting.js +++ b/packages/ckeditor5-font/src/fontsize/fontsizeediting.js @@ -9,6 +9,7 @@ import { Plugin } from 'ckeditor5/src/core'; import { CKEditorError } from 'ckeditor5/src/utils'; +import { isLength, isPercentage } from 'ckeditor5/src/engine'; import FontSizeCommand from './fontsizecommand'; import { normalizeOptions } from './utils'; @@ -109,7 +110,9 @@ export default class FontSizeEditing extends Plugin { const editor = this.editor; // If `fontSize.supportAllValues=true`, we do not allow to use named presets in the plugin's configuration. - const presets = definition.model.values.filter( value => !String( value ).match( /[\d.][\w%]+/ ) ); + const presets = definition.model.values.filter( value => { + return !isLength( String( value ) ) && !isPercentage( String( value ) ); + } ); if ( presets.length ) { /** diff --git a/packages/ckeditor5-font/tests/fontsize/fontsizeediting.js b/packages/ckeditor5-font/tests/fontsize/fontsizeediting.js index e2e37f03b02..4a7b310808e 100644 --- a/packages/ckeditor5-font/tests/fontsize/fontsizeediting.js +++ b/packages/ckeditor5-font/tests/fontsize/fontsizeediting.js @@ -76,7 +76,7 @@ describe( 'FontSizeEditing', () => { '10px', 12, { - model: 14, + model: '14px', title: '14px' } ] diff --git a/packages/ckeditor5-link/src/autolink.js b/packages/ckeditor5-link/src/autolink.js index 6c8d5a25871..5032ebbfb7e 100644 --- a/packages/ckeditor5-link/src/autolink.js +++ b/packages/ckeditor5-link/src/autolink.js @@ -40,7 +40,7 @@ const URL_REG_EXP = new RegExp( // Do not allow `www.foo` - see https://github.com/ckeditor/ckeditor5/issues/8050. '((?!www\\.)|(www\\.))' + // Host & domain names. - '(?![-_])(?:[-\\w\\u00a1-\\uffff]{0,63}[^-_]\\.)+' + + '(?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}[a-z0-9\\u00a1-\\uffff]\\.)+' + // TLD identifier name. '(?:[a-z\\u00a1-\\uffff]{2,})' + ')' + diff --git a/packages/ckeditor5-media-embed/src/automediaembed.js b/packages/ckeditor5-media-embed/src/automediaembed.js index b523ebca5fd..d9ceca358c3 100644 --- a/packages/ckeditor5-media-embed/src/automediaembed.js +++ b/packages/ckeditor5-media-embed/src/automediaembed.js @@ -16,7 +16,7 @@ import { global } from 'ckeditor5/src/utils'; import MediaEmbedEditing from './mediaembedediting'; import { insertMedia } from './utils'; -const URL_REGEXP = /^(?:http(s)?:\/\/)?[\w.-][\w-.~:/?#[\]@!$&'()*+,;=%]+$/; +const URL_REGEXP = /^(?:http(s)?:\/\/)?[\w-]+\.[\w-.~:/?#[\]@!$&'()*+,;=%]+$/; /** * The auto-media embed plugin. It recognizes media links in the pasted content and embeds