Skip to content

Commit

Permalink
Escape at point of output
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed May 13, 2022
1 parent d385420 commit 4ea320a
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions packages/block-library/src/navigation-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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( '-', '_' );
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 4ea320a

Please sign in to comment.