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
47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group formatting
|
|
*/
|
|
class Tests_Formatting_JSEscape extends WP_UnitTestCase {
|
|
function test_js_escape_simple() {
|
|
$out = esc_js('foo bar baz();');
|
|
$this->assertEquals('foo bar baz();', $out);
|
|
}
|
|
|
|
function test_js_escape_quotes() {
|
|
$out = esc_js('foo "bar" \'baz\'');
|
|
// does it make any sense to change " into "? Why not \"?
|
|
$this->assertEquals("foo "bar" \'baz\'", $out);
|
|
}
|
|
|
|
function test_js_escape_backslash() {
|
|
$bs = '\\';
|
|
$out = esc_js('foo '.$bs.'t bar '.$bs.$bs.' baz');
|
|
// \t becomes t - bug?
|
|
$this->assertEquals('foo t bar '.$bs.$bs.' baz', $out);
|
|
}
|
|
|
|
function test_js_escape_amp() {
|
|
$out = esc_js('foo & bar &baz; ');
|
|
$this->assertEquals("foo & bar &baz; ", $out);
|
|
}
|
|
|
|
function test_js_escape_quote_entity() {
|
|
$out = esc_js('foo ' bar ' baz &');
|
|
$this->assertEquals("foo \\' bar \\' baz &", $out);
|
|
}
|
|
|
|
function test_js_no_carriage_return() {
|
|
$out = esc_js("foo\rbar\nbaz\r");
|
|
// \r is stripped
|
|
$this->assertequals("foobar\\nbaz", $out);
|
|
}
|
|
|
|
function test_js_escape_rn() {
|
|
$out = esc_js("foo\r\nbar\nbaz\r\n");
|
|
// \r is stripped
|
|
$this->assertequals("foo\\nbar\\nbaz\\n", $out);
|
|
}
|
|
}
|