Skip to content

Commit

Permalink
Use @wordpress/escape-html escapeHTML in Link UI in preference to Lod…
Browse files Browse the repository at this point in the history
…ash method (#46184)

* Use WP escape package in block library

* Utilise WP method over lodash method
  • Loading branch information
getdave authored Nov 30, 2022
1 parent d5c68c8 commit 8ee32ce
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 24 deletions.
35 changes: 18 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/block-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"@wordpress/deprecated": "file:../deprecated",
"@wordpress/dom": "file:../dom",
"@wordpress/element": "file:../element",
"@wordpress/escape-html": "file:../escape-html",
"@wordpress/hooks": "file:../hooks",
"@wordpress/html-entities": "file:../html-entities",
"@wordpress/i18n": "file:../i18n",
Expand Down
10 changes: 3 additions & 7 deletions packages/block-library/src/navigation-link/update-attributes.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
/**
* External dependencies
*/
import escapeHtml from 'escape-html';

/**
* WordPress dependencies
*/
import { safeDecodeURI } from '@wordpress/url';
import { escapeHTML } from '@wordpress/escape-html';

/**
* @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind
Expand Down Expand Up @@ -78,8 +74,8 @@ export const updateAttributes = (
// - https://github.com/WordPress/gutenberg/pull/41063
// - https://github.com/WordPress/gutenberg/pull/18617.
const label = useNewLabel
? escapeHtml( newLabel )
: originalLabel || escapeHtml( newUrlWithoutHttp );
? escapeHTML( newLabel )
: originalLabel || escapeHTML( newUrlWithoutHttp );

// 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

0 comments on commit 8ee32ce

Please sign in to comment.