Skip to content

Commit

Permalink
Unescape HTML entities in category names
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla committed Aug 3, 2017
1 parent 0fa3f29 commit 428d791
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions blocks/library/categories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { Component } from '@wordpress/element';
import { Placeholder, Spinner } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { unescape } from 'lodash';

/**
* Internal dependencies
Expand Down Expand Up @@ -95,6 +96,14 @@ registerBlockType( 'core/categories', {
return `${ className }__list ${ className }__list-level-${ level }`;
}

renderCategoryName( category ) {
if ( ! category.name ) {
return __( '(Untitled)' );
}

return unescape( category.name ).trim();
}

renderCategoryList() {
const { showHierarchy } = this.props.attributes;
const parentId = showHierarchy ? 0 : null;
Expand All @@ -113,7 +122,7 @@ registerBlockType( 'core/categories', {

return (
<li key={ category.id }>
<a href={ category.link } target="_blank">{ category.name.trim() || __( '(Untitled)' ) }</a>
<a href={ category.link } target="_blank">{ this.renderCategoryName( category ) }</a>
{ showPostCounts &&
<span className={ `${ this.props.className }__post-count` }>
{ ' ' }({ category.count })
Expand Down Expand Up @@ -151,7 +160,7 @@ registerBlockType( 'core/categories', {
return [
<option key={ category.id }>
{ new Array( level * 3 ).fill( '\xa0' ) }
{ category.name.trim() || __( '(Untitled)' ) }
{ this.renderCategoryName( category ) }
{
!! showPostCounts
? ` ( ${ category.count } )`
Expand Down

0 comments on commit 428d791

Please sign in to comment.