From 4ea320aecd2baa4e36d299553170690e58541276 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Fri, 13 May 2022 20:59:28 +0100 Subject: [PATCH] Escape at point of output --- .../block-library/src/navigation-link/edit.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/packages/block-library/src/navigation-link/edit.js b/packages/block-library/src/navigation-link/edit.js index 7d6dab8725332..daf8f696f4183 100644 --- a/packages/block-library/src/navigation-link/edit.js +++ b/packages/block-library/src/navigation-link/edit.js @@ -233,19 +233,10 @@ export const updateNavigationLinkBlockAttributes = ( kind: newKind = originalKind, type: newType = originalType, } = updatedValue; - const normalizedTitle = title.replace( /http(s?):\/\//gi, '' ); - const normalizedURL = url.replace( /http(s?):\/\//gi, '' ); - - const shouldEscapeTitle = - title !== '' && - normalizedTitle !== normalizedURL && - originalLabel !== title; - const decodedTitle = decodeEntities( title ); + const normalizedURL = url.replace( /http(s?):\/\//gi, '' ); - const label = shouldEscapeTitle - ? decodedTitle - : originalLabel || escape( normalizedURL ); + const label = decodeEntities( title ) || originalLabel || normalizedURL; // In https://github.com/WordPress/gutenberg/pull/24670 we decided to use "tag" in favor of "post_tag" const type = newType === 'post_tag' ? 'tag' : newType.replace( '-', '_' ); @@ -746,7 +737,7 @@ export default function NavigationLinkEdit( { ref={ ref } identifier="label" className="wp-block-navigation-item__label" - value={ label } + value={ escape( label ) } onChange={ ( labelValue ) => setAttributes( { label: labelValue,