diff --git a/packages/element/src/test/index.js b/packages/element/src/test/index.js index 5d8417859042df..ef5bd4bb87542b 100644 --- a/packages/element/src/test/index.js +++ b/packages/element/src/test/index.js @@ -53,7 +53,7 @@ describe( 'element', () => { }, '<"WordPress" & Friends>' ) ); expect( result ).toBe( - '' + + '' + '<"WordPress" & Friends>' + '' ); diff --git a/packages/element/src/test/serialize.js b/packages/element/src/test/serialize.js index d0f5d9ef32b3ac..7fe4251666decd 100644 --- a/packages/element/src/test/serialize.js +++ b/packages/element/src/test/serialize.js @@ -528,7 +528,7 @@ describe( 'renderAttributes()', () => { href: '/index.php?foo=bar&qux=<"scary">', } ); - expect( result ).toBe( ' style="background:url("foo.png")" href="/index.php?foo=bar&qux=<"scary">"' ); + expect( result ).toBe( ' style="background:url("foo.png")" href="/index.php?foo=bar&qux=<"scary">"' ); } ); it( 'should render numeric attributes', () => { diff --git a/packages/escape-html/src/index.js b/packages/escape-html/src/index.js index 6b3f74e834564d..8bcc0a61da631f 100644 --- a/packages/escape-html/src/index.js +++ b/packages/escape-html/src/index.js @@ -51,6 +51,17 @@ export function escapeLessThan( value ) { return value.replace( //g, '>' ); +} + /** * Returns an escaped attribute value. * @@ -64,7 +75,7 @@ export function escapeLessThan( value ) { * @return {string} Escaped attribute value. */ export function escapeAttribute( value ) { - return escapeQuotationMark( escapeAmpersand( value ) ); + return escapeGreaterThan( escapeQuotationMark( escapeAmpersand( value ) ) ); } /** diff --git a/packages/escape-html/src/test/index.js b/packages/escape-html/src/test/index.js index 65b3e09dfcfe19..60a35126d04633 100644 --- a/packages/escape-html/src/test/index.js +++ b/packages/escape-html/src/test/index.js @@ -5,11 +5,19 @@ import { escapeAmpersand, escapeQuotationMark, escapeLessThan, + escapeGreaterThan, escapeAttribute, escapeHTML, isValidAttributeName, } from '../'; +function testEscapeGreaterThan( implementation ) { + it( 'should escape greater than', () => { + const result = implementation( 'Chicken > Ribs' ); + expect( result ).toBe( 'Chicken > Ribs' ); + } ); +} + function testEscapeAmpersand( implementation ) { it( 'should escape ampersand', () => { const result = implementation( 'foo & bar & & baz Σ &#bad; Σ Σ vil;' ); @@ -46,9 +54,14 @@ describe( 'escapeLessThan', () => { testEscapeLessThan( escapeLessThan ); } ); +describe( 'escapeGreaterThan', () => { + testEscapeGreaterThan( escapeGreaterThan ); +} ); + describe( 'escapeAttribute', () => { testEscapeAmpersand( escapeAttribute ); testEscapeQuotationMark( escapeAttribute ); + testEscapeGreaterThan( escapeAttribute ); } ); describe( 'escapeHTML', () => {