mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Don't nest `esc_attr()` and `htmlspecialchars()` when escaping the post title on the edit post screen. Unrevert parts of [32851] and [32850]. Adds/alters unit tests. Props miqrogroove. Fixes #17780. git-svn-id: https://develop.svn.wordpress.org/trunk@33271 602fd350-edb4-49c9-b593-d223f7449a82
33 lines
998 B
PHP
33 lines
998 B
PHP
<?php
|
|
|
|
/**
|
|
* @group formatting
|
|
*/
|
|
class Tests_Formatting_EscAttr extends WP_UnitTestCase {
|
|
function test_esc_attr_quotes() {
|
|
$attr = '"double quotes"';
|
|
$this->assertEquals( '"double quotes"', esc_attr( $attr ) );
|
|
|
|
$attr = "'single quotes'";
|
|
$this->assertEquals( ''single quotes'', esc_attr( $attr ) );
|
|
|
|
$attr = "'mixed' " . '"quotes"';
|
|
$this->assertEquals( ''mixed' "quotes"', esc_attr( $attr ) );
|
|
|
|
// Handles double encoding?
|
|
$attr = '"double quotes"';
|
|
$this->assertEquals( '"double quotes"', esc_attr( esc_attr( $attr ) ) );
|
|
|
|
$attr = "'single quotes'";
|
|
$this->assertEquals( ''single quotes'', esc_attr( esc_attr( $attr ) ) );
|
|
|
|
$attr = "'mixed' " . '"quotes"';
|
|
$this->assertEquals( ''mixed' "quotes"', esc_attr( esc_attr( $attr ) ) );
|
|
}
|
|
|
|
function test_esc_attr_amp() {
|
|
$out = esc_attr( 'foo & bar &baz; ' );
|
|
$this->assertEquals( "foo & bar &baz; ", $out );
|
|
}
|
|
}
|