<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[53557] trunk/tests/phpunit/tests: Code Modernization: Remove dynamic properties in `Tests_*_Slashes`.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/53557">53557</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/53557","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2022-06-23 14:24:08 +0000 (Thu, 23 Jun 2022)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Code Modernization: Remove dynamic properties in `Tests_*_Slashes`.
Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.
In this particular case, the test classes contain a `set_up()` method that sets a group of properties, which are ''used'' by the tests, but the values of these properties are never ''changed'' by the tests.
In other words, setting these properties in the `set_up()` is an unnecessary overhead and the properties should be changed to class constants.
Follow-up to [1041/tests], [1071/tests].
Props jrf.
See <a href="https://core.trac.wordpress.org/ticket/56033">#56033</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsattachmentslashesphp">trunk/tests/phpunit/tests/attachment/slashes.php</a></li>
<li><a href="#trunktestsphpunittestscommentslashesphp">trunk/tests/phpunit/tests/comment/slashes.php</a></li>
<li><a href="#trunktestsphpunittestsmetaslashesphp">trunk/tests/phpunit/tests/meta/slashes.php</a></li>
<li><a href="#trunktestsphpunittestsoptionslashesphp">trunk/tests/phpunit/tests/option/slashes.php</a></li>
<li><a href="#trunktestsphpunittestspostslashesphp">trunk/tests/phpunit/tests/post/slashes.php</a></li>
<li><a href="#trunktestsphpunitteststermslashesphp">trunk/tests/phpunit/tests/term/slashes.php</a></li>
<li><a href="#trunktestsphpunittestsuserslashesphp">trunk/tests/phpunit/tests/user/slashes.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunittestsattachmentslashesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/attachment/slashes.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/attachment/slashes.php 2022-06-22 16:50:14 UTC (rev 53556)
+++ trunk/tests/phpunit/tests/attachment/slashes.php 2022-06-23 14:24:08 UTC (rev 53557)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6,6 +6,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 21767
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_Attachment_Slashes extends WP_UnitTestCase {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /*
+ * It is important to test with both even and odd numbered slashes,
+ * as KSES does a strip-then-add slashes in some of its function calls.
+ */
+
+ const SLASH_1 = 'String with 1 slash \\';
+ const SLASH_2 = 'String with 2 slashes \\\\';
+ const SLASH_3 = 'String with 3 slashes \\\\\\';
+ const SLASH_4 = 'String with 4 slashes \\\\\\\\';
+ const SLASH_5 = 'String with 5 slashes \\\\\\\\\\';
+ const SLASH_6 = 'String with 6 slashes \\\\\\\\\\\\';
+ const SLASH_7 = 'String with 7 slashes \\\\\\\\\\\\\\';
+
</ins><span class="cx" style="display: block; padding: 0 10px"> protected static $author_id;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -16,16 +30,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> parent::set_up();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$author_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- // It is important to test with both even and odd numbered slashes,
- // as KSES does a strip-then-add slashes in some of its function calls.
- $this->slash_1 = 'String with 1 slash \\';
- $this->slash_2 = 'String with 2 slashes \\\\';
- $this->slash_3 = 'String with 3 slashes \\\\\\';
- $this->slash_4 = 'String with 4 slashes \\\\\\\\';
- $this->slash_5 = 'String with 5 slashes \\\\\\\\\\';
- $this->slash_6 = 'String with 6 slashes \\\\\\\\\\\\';
- $this->slash_7 = 'String with 7 slashes \\\\\\\\\\\\\\';
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -35,32 +39,32 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = wp_insert_attachment(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'publish',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_title' => $this->slash_1,
- 'post_content_filtered' => $this->slash_3,
- 'post_excerpt' => $this->slash_5,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_title' => self::SLASH_1,
+ 'post_content_filtered' => self::SLASH_3,
+ 'post_excerpt' => self::SLASH_5,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_type' => 'post',
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_1 ), $post->post_title );
- $this->assertSame( wp_unslash( $this->slash_3 ), $post->post_content_filtered );
- $this->assertSame( wp_unslash( $this->slash_5 ), $post->post_excerpt );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_1 ), $post->post_title );
+ $this->assertSame( wp_unslash( self::SLASH_3 ), $post->post_content_filtered );
+ $this->assertSame( wp_unslash( self::SLASH_5 ), $post->post_excerpt );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = wp_insert_attachment(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'publish',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_title' => $this->slash_2,
- 'post_content_filtered' => $this->slash_4,
- 'post_excerpt' => $this->slash_6,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_title' => self::SLASH_2,
+ 'post_content_filtered' => self::SLASH_4,
+ 'post_excerpt' => self::SLASH_6,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_type' => 'post',
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_2 ), $post->post_title );
- $this->assertSame( wp_unslash( $this->slash_4 ), $post->post_content_filtered );
- $this->assertSame( wp_unslash( $this->slash_6 ), $post->post_excerpt );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_2 ), $post->post_title );
+ $this->assertSame( wp_unslash( self::SLASH_4 ), $post->post_content_filtered );
+ $this->assertSame( wp_unslash( self::SLASH_6 ), $post->post_excerpt );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestscommentslashesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/comment/slashes.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/comment/slashes.php 2022-06-22 16:50:14 UTC (rev 53556)
+++ trunk/tests/phpunit/tests/comment/slashes.php 2022-06-23 14:24:08 UTC (rev 53557)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6,6 +6,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 21767
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_Comment_Slashes extends WP_UnitTestCase {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /*
+ * It is important to test with both even and odd numbered slashes,
+ * as KSES does a strip-then-add slashes in some of its function calls.
+ */
+
+ const SLASH_1 = 'String with 1 slash \\';
+ const SLASH_2 = 'String with 2 slashes \\\\';
+ const SLASH_3 = 'String with 3 slashes \\\\\\';
+ const SLASH_4 = 'String with 4 slashes \\\\\\\\';
+ const SLASH_5 = 'String with 5 slashes \\\\\\\\\\';
+ const SLASH_6 = 'String with 6 slashes \\\\\\\\\\\\';
+ const SLASH_7 = 'String with 7 slashes \\\\\\\\\\\\\\';
+
</ins><span class="cx" style="display: block; padding: 0 10px"> protected static $author_id;
</span><span class="cx" style="display: block; padding: 0 10px"> protected static $post_id;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -19,16 +33,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> parent::set_up();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$author_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- // It is important to test with both even and odd numbered slashes,
- // as KSES does a strip-then-add slashes in some of its function calls.
- $this->slash_1 = 'String with 1 slash \\';
- $this->slash_2 = 'String with 2 slashes \\\\';
- $this->slash_3 = 'String with 3 slashes \\\\\\';
- $this->slash_4 = 'String with 4 slashes \\\\\\\\';
- $this->slash_5 = 'String with 5 slashes \\\\\\\\\\';
- $this->slash_6 = 'String with 6 slashes \\\\\\\\\\\\';
- $this->slash_7 = 'String with 7 slashes \\\\\\\\\\\\\\';
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -41,33 +45,33 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // as slashes are not permitted in that data.
</span><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_post_ID' => $post_id,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_author' => $this->slash_1,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_author' => self::SLASH_1,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment_author_url' => '',
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_author_email' => '',
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_type' => '',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_content' => $this->slash_7,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_content' => self::SLASH_7,
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_id = wp_new_comment( $data );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $comment = get_comment( $comment_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_1 ), $comment->comment_author );
- $this->assertSame( wp_unslash( $this->slash_7 ), $comment->comment_content );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_1 ), $comment->comment_author );
+ $this->assertSame( wp_unslash( self::SLASH_7 ), $comment->comment_content );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $data = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_post_ID' => $post_id,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_author' => $this->slash_2,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_author' => self::SLASH_2,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment_author_url' => '',
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_author_email' => '',
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_type' => '',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_content' => $this->slash_4,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_content' => self::SLASH_4,
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_id = wp_new_comment( $data );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $comment = get_comment( $comment_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_2 ), $comment->comment_author );
- $this->assertSame( wp_unslash( $this->slash_4 ), $comment->comment_content );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_2 ), $comment->comment_author );
+ $this->assertSame( wp_unslash( self::SLASH_4 ), $comment->comment_content );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -86,10 +90,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST = array();
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['comment_ID'] = $comment_id;
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['comment_status'] = '';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $_POST['newcomment_author'] = $this->slash_1;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_POST['newcomment_author'] = self::SLASH_1;
</ins><span class="cx" style="display: block; padding: 0 10px"> $_POST['newcomment_author_url'] = '';
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['newcomment_author_email'] = '';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $_POST['content'] = $this->slash_7;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_POST['content'] = self::SLASH_7;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST = add_magic_quotes( $_POST ); // The edit_comment() function will strip slashes.
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -96,16 +100,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> edit_comment();
</span><span class="cx" style="display: block; padding: 0 10px"> $comment = get_comment( $comment_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $this->slash_1, $comment->comment_author );
- $this->assertSame( $this->slash_7, $comment->comment_content );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( self::SLASH_1, $comment->comment_author );
+ $this->assertSame( self::SLASH_7, $comment->comment_content );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST = array();
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['comment_ID'] = $comment_id;
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['comment_status'] = '';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $_POST['newcomment_author'] = $this->slash_2;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_POST['newcomment_author'] = self::SLASH_2;
</ins><span class="cx" style="display: block; padding: 0 10px"> $_POST['newcomment_author_url'] = '';
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['newcomment_author_email'] = '';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $_POST['content'] = $this->slash_4;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_POST['content'] = self::SLASH_4;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST = add_magic_quotes( $_POST ); // The edit_comment() function will strip slashes.
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -112,8 +116,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> edit_comment();
</span><span class="cx" style="display: block; padding: 0 10px"> $comment = get_comment( $comment_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $this->slash_2, $comment->comment_author );
- $this->assertSame( $this->slash_4, $comment->comment_content );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( self::SLASH_2, $comment->comment_author );
+ $this->assertSame( self::SLASH_4, $comment->comment_content );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -125,26 +129,26 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_id = wp_insert_comment(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_post_ID' => $post_id,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_author' => $this->slash_1,
- 'comment_content' => $this->slash_7,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_author' => self::SLASH_1,
+ 'comment_content' => self::SLASH_7,
</ins><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $comment = get_comment( $comment_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_1 ), $comment->comment_author );
- $this->assertSame( wp_unslash( $this->slash_7 ), $comment->comment_content );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_1 ), $comment->comment_author );
+ $this->assertSame( wp_unslash( self::SLASH_7 ), $comment->comment_content );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_id = wp_insert_comment(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_post_ID' => $post_id,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_author' => $this->slash_2,
- 'comment_content' => $this->slash_4,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_author' => self::SLASH_2,
+ 'comment_content' => self::SLASH_4,
</ins><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $comment = get_comment( $comment_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_2 ), $comment->comment_author );
- $this->assertSame( wp_unslash( $this->slash_4 ), $comment->comment_content );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_2 ), $comment->comment_author );
+ $this->assertSame( wp_unslash( self::SLASH_4 ), $comment->comment_content );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -161,26 +165,26 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_update_comment(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_ID' => $comment_id,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_author' => $this->slash_1,
- 'comment_content' => $this->slash_7,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_author' => self::SLASH_1,
+ 'comment_content' => self::SLASH_7,
</ins><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $comment = get_comment( $comment_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_1 ), $comment->comment_author );
- $this->assertSame( wp_unslash( $this->slash_7 ), $comment->comment_content );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_1 ), $comment->comment_author );
+ $this->assertSame( wp_unslash( self::SLASH_7 ), $comment->comment_content );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_update_comment(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_ID' => $comment_id,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_author' => $this->slash_2,
- 'comment_content' => $this->slash_4,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_author' => self::SLASH_2,
+ 'comment_content' => self::SLASH_4,
</ins><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $comment = get_comment( $comment_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_2 ), $comment->comment_author );
- $this->assertSame( wp_unslash( $this->slash_4 ), $comment->comment_content );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_2 ), $comment->comment_author );
+ $this->assertSame( wp_unslash( self::SLASH_4 ), $comment->comment_content );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsmetaslashesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/meta/slashes.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/meta/slashes.php 2022-06-22 16:50:14 UTC (rev 53556)
+++ trunk/tests/phpunit/tests/meta/slashes.php 2022-06-23 14:24:08 UTC (rev 53557)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6,6 +6,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 21767
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_Meta_Slashes extends WP_UnitTestCase {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /*
+ * It is important to test with both even and odd numbered slashes,
+ * as KSES does a strip-then-add slashes in some of its function calls.
+ */
+
+ const SLASH_1 = 'String with 1 slash \\';
+ const SLASH_2 = 'String with 2 slashes \\\\';
+ const SLASH_3 = 'String with 3 slashes \\\\\\';
+ const SLASH_4 = 'String with 4 slashes \\\\\\\\';
+ const SLASH_5 = 'String with 5 slashes \\\\\\\\\\';
+ const SLASH_6 = 'String with 6 slashes \\\\\\\\\\\\';
+ const SLASH_7 = 'String with 7 slashes \\\\\\\\\\\\\\';
+
</ins><span class="cx" style="display: block; padding: 0 10px"> protected static $editor_id;
</span><span class="cx" style="display: block; padding: 0 10px"> protected static $post_id;
</span><span class="cx" style="display: block; padding: 0 10px"> protected static $comment_id;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -22,14 +36,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> parent::set_up();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$editor_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- $this->slash_1 = 'String with 1 slash \\';
- $this->slash_2 = 'String with 2 slashes \\\\';
- $this->slash_3 = 'String with 3 slashes \\\\\\';
- $this->slash_4 = 'String with 4 slashes \\\\\\\\';
- $this->slash_5 = 'String with 5 slashes \\\\\\\\\\';
- $this->slash_6 = 'String with 6 slashes \\\\\\\\\\\\';
- $this->slash_7 = 'String with 7 slashes \\\\\\\\\\\\\\';
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -53,19 +59,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['post_ID'] = $post_id;
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['metakeyselect'] = '#NONE#';
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['metakeyinput'] = 'slash_test_0';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $_POST['metavalue'] = $this->slash_6;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_POST['metavalue'] = self::SLASH_6;
</ins><span class="cx" style="display: block; padding: 0 10px"> $_POST['meta'] = array(
</span><span class="cx" style="display: block; padding: 0 10px"> $meta_1 => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'key' => 'slash_test_1',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'value' => $this->slash_1,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'value' => self::SLASH_1,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> $meta_2 => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'key' => 'slash_test_2',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'value' => $this->slash_3,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'value' => self::SLASH_3,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> $meta_3 => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'key' => 'slash_test_3',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'value' => $this->slash_4,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'value' => self::SLASH_4,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -74,28 +80,28 @@
</span><span class="cx" style="display: block; padding: 0 10px"> edit_post();
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $this->slash_6, get_post_meta( $post_id, 'slash_test_0', true ) );
- $this->assertSame( $this->slash_1, get_post_meta( $post_id, 'slash_test_1', true ) );
- $this->assertSame( $this->slash_3, get_post_meta( $post_id, 'slash_test_2', true ) );
- $this->assertSame( $this->slash_4, get_post_meta( $post_id, 'slash_test_3', true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( self::SLASH_6, get_post_meta( $post_id, 'slash_test_0', true ) );
+ $this->assertSame( self::SLASH_1, get_post_meta( $post_id, 'slash_test_1', true ) );
+ $this->assertSame( self::SLASH_3, get_post_meta( $post_id, 'slash_test_2', true ) );
+ $this->assertSame( self::SLASH_4, get_post_meta( $post_id, 'slash_test_3', true ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST = array();
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['post_ID'] = $post_id;
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['metakeyselect'] = '#NONE#';
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['metakeyinput'] = 'slash_test_0';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $_POST['metavalue'] = $this->slash_7;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_POST['metavalue'] = self::SLASH_7;
</ins><span class="cx" style="display: block; padding: 0 10px"> $_POST['meta'] = array(
</span><span class="cx" style="display: block; padding: 0 10px"> $meta_1 => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'key' => 'slash_test_1',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'value' => $this->slash_2,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'value' => self::SLASH_2,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> $meta_2 => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'key' => 'slash_test_2',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'value' => $this->slash_4,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'value' => self::SLASH_4,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> $meta_3 => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'key' => 'slash_test_3',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'value' => $this->slash_5,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'value' => self::SLASH_5,
</ins><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -104,9 +110,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> edit_post();
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $this->slash_2, get_post_meta( $post_id, 'slash_test_1', true ) );
- $this->assertSame( $this->slash_4, get_post_meta( $post_id, 'slash_test_2', true ) );
- $this->assertSame( $this->slash_5, get_post_meta( $post_id, 'slash_test_3', true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( self::SLASH_2, get_post_meta( $post_id, 'slash_test_1', true ) );
+ $this->assertSame( self::SLASH_4, get_post_meta( $post_id, 'slash_test_2', true ) );
+ $this->assertSame( self::SLASH_5, get_post_meta( $post_id, 'slash_test_3', true ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -115,13 +121,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_add_post_meta() {
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = self::$post_id;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_post_meta( $post_id, 'slash_test_1', addslashes( $this->slash_1 ) );
- add_post_meta( $post_id, 'slash_test_2', addslashes( $this->slash_3 ) );
- add_post_meta( $post_id, 'slash_test_3', addslashes( $this->slash_4 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_post_meta( $post_id, 'slash_test_1', addslashes( self::SLASH_1 ) );
+ add_post_meta( $post_id, 'slash_test_2', addslashes( self::SLASH_3 ) );
+ add_post_meta( $post_id, 'slash_test_3', addslashes( self::SLASH_4 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $this->slash_1, get_post_meta( $post_id, 'slash_test_1', true ) );
- $this->assertSame( $this->slash_3, get_post_meta( $post_id, 'slash_test_2', true ) );
- $this->assertSame( $this->slash_4, get_post_meta( $post_id, 'slash_test_3', true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( self::SLASH_1, get_post_meta( $post_id, 'slash_test_1', true ) );
+ $this->assertSame( self::SLASH_3, get_post_meta( $post_id, 'slash_test_2', true ) );
+ $this->assertSame( self::SLASH_4, get_post_meta( $post_id, 'slash_test_3', true ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -130,13 +136,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_update_post_meta() {
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = self::$post_id;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_post_meta( $post_id, 'slash_test_1', addslashes( $this->slash_1 ) );
- update_post_meta( $post_id, 'slash_test_2', addslashes( $this->slash_3 ) );
- update_post_meta( $post_id, 'slash_test_3', addslashes( $this->slash_4 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_post_meta( $post_id, 'slash_test_1', addslashes( self::SLASH_1 ) );
+ update_post_meta( $post_id, 'slash_test_2', addslashes( self::SLASH_3 ) );
+ update_post_meta( $post_id, 'slash_test_3', addslashes( self::SLASH_4 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $this->slash_1, get_post_meta( $post_id, 'slash_test_1', true ) );
- $this->assertSame( $this->slash_3, get_post_meta( $post_id, 'slash_test_2', true ) );
- $this->assertSame( $this->slash_4, get_post_meta( $post_id, 'slash_test_3', true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( self::SLASH_1, get_post_meta( $post_id, 'slash_test_1', true ) );
+ $this->assertSame( self::SLASH_3, get_post_meta( $post_id, 'slash_test_2', true ) );
+ $this->assertSame( self::SLASH_4, get_post_meta( $post_id, 'slash_test_3', true ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -145,21 +151,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_add_comment_meta() {
</span><span class="cx" style="display: block; padding: 0 10px"> $comment_id = self::$comment_id;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_comment_meta( $comment_id, 'slash_test_1', $this->slash_1 );
- add_comment_meta( $comment_id, 'slash_test_2', $this->slash_3 );
- add_comment_meta( $comment_id, 'slash_test_3', $this->slash_5 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_comment_meta( $comment_id, 'slash_test_1', self::SLASH_1 );
+ add_comment_meta( $comment_id, 'slash_test_2', self::SLASH_3 );
+ add_comment_meta( $comment_id, 'slash_test_3', self::SLASH_5 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_1 ), get_comment_meta( $comment_id, 'slash_test_1', true ) );
- $this->assertSame( wp_unslash( $this->slash_3 ), get_comment_meta( $comment_id, 'slash_test_2', true ) );
- $this->assertSame( wp_unslash( $this->slash_5 ), get_comment_meta( $comment_id, 'slash_test_3', true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_1 ), get_comment_meta( $comment_id, 'slash_test_1', true ) );
+ $this->assertSame( wp_unslash( self::SLASH_3 ), get_comment_meta( $comment_id, 'slash_test_2', true ) );
+ $this->assertSame( wp_unslash( self::SLASH_5 ), get_comment_meta( $comment_id, 'slash_test_3', true ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_comment_meta( $comment_id, 'slash_test_4', $this->slash_2 );
- add_comment_meta( $comment_id, 'slash_test_5', $this->slash_4 );
- add_comment_meta( $comment_id, 'slash_test_6', $this->slash_6 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_comment_meta( $comment_id, 'slash_test_4', self::SLASH_2 );
+ add_comment_meta( $comment_id, 'slash_test_5', self::SLASH_4 );
+ add_comment_meta( $comment_id, 'slash_test_6', self::SLASH_6 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_2 ), get_comment_meta( $comment_id, 'slash_test_4', true ) );
- $this->assertSame( wp_unslash( $this->slash_4 ), get_comment_meta( $comment_id, 'slash_test_5', true ) );
- $this->assertSame( wp_unslash( $this->slash_6 ), get_comment_meta( $comment_id, 'slash_test_6', true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_2 ), get_comment_meta( $comment_id, 'slash_test_4', true ) );
+ $this->assertSame( wp_unslash( self::SLASH_4 ), get_comment_meta( $comment_id, 'slash_test_5', true ) );
+ $this->assertSame( wp_unslash( self::SLASH_6 ), get_comment_meta( $comment_id, 'slash_test_6', true ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -172,21 +178,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> add_comment_meta( $comment_id, 'slash_test_2', 'foo' );
</span><span class="cx" style="display: block; padding: 0 10px"> add_comment_meta( $comment_id, 'slash_test_3', 'foo' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_comment_meta( $comment_id, 'slash_test_1', $this->slash_1 );
- update_comment_meta( $comment_id, 'slash_test_2', $this->slash_3 );
- update_comment_meta( $comment_id, 'slash_test_3', $this->slash_5 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_comment_meta( $comment_id, 'slash_test_1', self::SLASH_1 );
+ update_comment_meta( $comment_id, 'slash_test_2', self::SLASH_3 );
+ update_comment_meta( $comment_id, 'slash_test_3', self::SLASH_5 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_1 ), get_comment_meta( $comment_id, 'slash_test_1', true ) );
- $this->assertSame( wp_unslash( $this->slash_3 ), get_comment_meta( $comment_id, 'slash_test_2', true ) );
- $this->assertSame( wp_unslash( $this->slash_5 ), get_comment_meta( $comment_id, 'slash_test_3', true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_1 ), get_comment_meta( $comment_id, 'slash_test_1', true ) );
+ $this->assertSame( wp_unslash( self::SLASH_3 ), get_comment_meta( $comment_id, 'slash_test_2', true ) );
+ $this->assertSame( wp_unslash( self::SLASH_5 ), get_comment_meta( $comment_id, 'slash_test_3', true ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_comment_meta( $comment_id, 'slash_test_1', $this->slash_2 );
- update_comment_meta( $comment_id, 'slash_test_2', $this->slash_4 );
- update_comment_meta( $comment_id, 'slash_test_3', $this->slash_6 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_comment_meta( $comment_id, 'slash_test_1', self::SLASH_2 );
+ update_comment_meta( $comment_id, 'slash_test_2', self::SLASH_4 );
+ update_comment_meta( $comment_id, 'slash_test_3', self::SLASH_6 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_2 ), get_comment_meta( $comment_id, 'slash_test_1', true ) );
- $this->assertSame( wp_unslash( $this->slash_4 ), get_comment_meta( $comment_id, 'slash_test_2', true ) );
- $this->assertSame( wp_unslash( $this->slash_6 ), get_comment_meta( $comment_id, 'slash_test_3', true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_2 ), get_comment_meta( $comment_id, 'slash_test_1', true ) );
+ $this->assertSame( wp_unslash( self::SLASH_4 ), get_comment_meta( $comment_id, 'slash_test_2', true ) );
+ $this->assertSame( wp_unslash( self::SLASH_6 ), get_comment_meta( $comment_id, 'slash_test_3', true ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -195,21 +201,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_add_user_meta() {
</span><span class="cx" style="display: block; padding: 0 10px"> $user_id = self::$user_id;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_user_meta( $user_id, 'slash_test_1', $this->slash_1 );
- add_user_meta( $user_id, 'slash_test_2', $this->slash_3 );
- add_user_meta( $user_id, 'slash_test_3', $this->slash_5 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_user_meta( $user_id, 'slash_test_1', self::SLASH_1 );
+ add_user_meta( $user_id, 'slash_test_2', self::SLASH_3 );
+ add_user_meta( $user_id, 'slash_test_3', self::SLASH_5 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_1 ), get_user_meta( $user_id, 'slash_test_1', true ) );
- $this->assertSame( wp_unslash( $this->slash_3 ), get_user_meta( $user_id, 'slash_test_2', true ) );
- $this->assertSame( wp_unslash( $this->slash_5 ), get_user_meta( $user_id, 'slash_test_3', true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_1 ), get_user_meta( $user_id, 'slash_test_1', true ) );
+ $this->assertSame( wp_unslash( self::SLASH_3 ), get_user_meta( $user_id, 'slash_test_2', true ) );
+ $this->assertSame( wp_unslash( self::SLASH_5 ), get_user_meta( $user_id, 'slash_test_3', true ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_user_meta( $user_id, 'slash_test_4', $this->slash_2 );
- add_user_meta( $user_id, 'slash_test_5', $this->slash_4 );
- add_user_meta( $user_id, 'slash_test_6', $this->slash_6 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_user_meta( $user_id, 'slash_test_4', self::SLASH_2 );
+ add_user_meta( $user_id, 'slash_test_5', self::SLASH_4 );
+ add_user_meta( $user_id, 'slash_test_6', self::SLASH_6 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_2 ), get_user_meta( $user_id, 'slash_test_4', true ) );
- $this->assertSame( wp_unslash( $this->slash_4 ), get_user_meta( $user_id, 'slash_test_5', true ) );
- $this->assertSame( wp_unslash( $this->slash_6 ), get_user_meta( $user_id, 'slash_test_6', true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_2 ), get_user_meta( $user_id, 'slash_test_4', true ) );
+ $this->assertSame( wp_unslash( self::SLASH_4 ), get_user_meta( $user_id, 'slash_test_5', true ) );
+ $this->assertSame( wp_unslash( self::SLASH_6 ), get_user_meta( $user_id, 'slash_test_6', true ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -222,20 +228,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> add_user_meta( $user_id, 'slash_test_2', 'foo' );
</span><span class="cx" style="display: block; padding: 0 10px"> add_user_meta( $user_id, 'slash_test_3', 'foo' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_user_meta( $user_id, 'slash_test_1', $this->slash_1 );
- update_user_meta( $user_id, 'slash_test_2', $this->slash_3 );
- update_user_meta( $user_id, 'slash_test_3', $this->slash_5 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_user_meta( $user_id, 'slash_test_1', self::SLASH_1 );
+ update_user_meta( $user_id, 'slash_test_2', self::SLASH_3 );
+ update_user_meta( $user_id, 'slash_test_3', self::SLASH_5 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_1 ), get_user_meta( $user_id, 'slash_test_1', true ) );
- $this->assertSame( wp_unslash( $this->slash_3 ), get_user_meta( $user_id, 'slash_test_2', true ) );
- $this->assertSame( wp_unslash( $this->slash_5 ), get_user_meta( $user_id, 'slash_test_3', true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_1 ), get_user_meta( $user_id, 'slash_test_1', true ) );
+ $this->assertSame( wp_unslash( self::SLASH_3 ), get_user_meta( $user_id, 'slash_test_2', true ) );
+ $this->assertSame( wp_unslash( self::SLASH_5 ), get_user_meta( $user_id, 'slash_test_3', true ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_user_meta( $user_id, 'slash_test_1', $this->slash_2 );
- update_user_meta( $user_id, 'slash_test_2', $this->slash_4 );
- update_user_meta( $user_id, 'slash_test_3', $this->slash_6 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_user_meta( $user_id, 'slash_test_1', self::SLASH_2 );
+ update_user_meta( $user_id, 'slash_test_2', self::SLASH_4 );
+ update_user_meta( $user_id, 'slash_test_3', self::SLASH_6 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_2 ), get_user_meta( $user_id, 'slash_test_1', true ) );
- $this->assertSame( wp_unslash( $this->slash_4 ), get_user_meta( $user_id, 'slash_test_2', true ) );
- $this->assertSame( wp_unslash( $this->slash_6 ), get_user_meta( $user_id, 'slash_test_3', true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_2 ), get_user_meta( $user_id, 'slash_test_1', true ) );
+ $this->assertSame( wp_unslash( self::SLASH_4 ), get_user_meta( $user_id, 'slash_test_2', true ) );
+ $this->assertSame( wp_unslash( self::SLASH_6 ), get_user_meta( $user_id, 'slash_test_3', true ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsoptionslashesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/option/slashes.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/option/slashes.php 2022-06-22 16:50:14 UTC (rev 53556)
+++ trunk/tests/phpunit/tests/option/slashes.php 2022-06-23 14:24:08 UTC (rev 53557)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7,33 +7,32 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_Option_Slashes extends WP_UnitTestCase {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function set_up() {
- parent::set_up();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /*
+ * It is important to test with both even and odd numbered slashes,
+ * as KSES does a strip-then-add slashes in some of its function calls.
+ */
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // It is important to test with both even and odd numbered slashes,
- // as KSES does a strip-then-add slashes in some of its function calls.
- $this->slash_1 = 'String with 1 slash \\';
- $this->slash_2 = 'String with 2 slashes \\\\';
- $this->slash_3 = 'String with 3 slashes \\\\\\';
- $this->slash_4 = 'String with 4 slashes \\\\\\\\';
- $this->slash_5 = 'String with 5 slashes \\\\\\\\\\';
- $this->slash_6 = 'String with 6 slashes \\\\\\\\\\\\';
- $this->slash_7 = 'String with 7 slashes \\\\\\\\\\\\\\';
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ const SLASH_1 = 'String with 1 slash \\';
+ const SLASH_2 = 'String with 2 slashes \\\\';
+ const SLASH_3 = 'String with 3 slashes \\\\\\';
+ const SLASH_4 = 'String with 4 slashes \\\\\\\\';
+ const SLASH_5 = 'String with 5 slashes \\\\\\\\\\';
+ const SLASH_6 = 'String with 6 slashes \\\\\\\\\\\\';
+ const SLASH_7 = 'String with 7 slashes \\\\\\\\\\\\\\';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Tests the model function that expects un-slashed data
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_add_option() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_option( 'slash_test_1', $this->slash_1 );
- add_option( 'slash_test_2', $this->slash_2 );
- add_option( 'slash_test_3', $this->slash_3 );
- add_option( 'slash_test_4', $this->slash_4 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_option( 'slash_test_1', self::SLASH_1 );
+ add_option( 'slash_test_2', self::SLASH_2 );
+ add_option( 'slash_test_3', self::SLASH_3 );
+ add_option( 'slash_test_4', self::SLASH_4 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $this->slash_1, get_option( 'slash_test_1' ) );
- $this->assertSame( $this->slash_2, get_option( 'slash_test_2' ) );
- $this->assertSame( $this->slash_3, get_option( 'slash_test_3' ) );
- $this->assertSame( $this->slash_4, get_option( 'slash_test_4' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( self::SLASH_1, get_option( 'slash_test_1' ) );
+ $this->assertSame( self::SLASH_2, get_option( 'slash_test_2' ) );
+ $this->assertSame( self::SLASH_3, get_option( 'slash_test_3' ) );
+ $this->assertSame( self::SLASH_4, get_option( 'slash_test_4' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -42,16 +41,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_update_option() {
</span><span class="cx" style="display: block; padding: 0 10px"> add_option( 'slash_test_5', 'foo' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_option( 'slash_test_5', $this->slash_1 );
- $this->assertSame( $this->slash_1, get_option( 'slash_test_5' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_option( 'slash_test_5', self::SLASH_1 );
+ $this->assertSame( self::SLASH_1, get_option( 'slash_test_5' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_option( 'slash_test_5', $this->slash_2 );
- $this->assertSame( $this->slash_2, get_option( 'slash_test_5' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_option( 'slash_test_5', self::SLASH_2 );
+ $this->assertSame( self::SLASH_2, get_option( 'slash_test_5' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_option( 'slash_test_5', $this->slash_3 );
- $this->assertSame( $this->slash_3, get_option( 'slash_test_5' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_option( 'slash_test_5', self::SLASH_3 );
+ $this->assertSame( self::SLASH_3, get_option( 'slash_test_5' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_option( 'slash_test_5', $this->slash_4 );
- $this->assertSame( $this->slash_4, get_option( 'slash_test_5' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_option( 'slash_test_5', self::SLASH_4 );
+ $this->assertSame( self::SLASH_4, get_option( 'slash_test_5' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestspostslashesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/post/slashes.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/post/slashes.php 2022-06-22 16:50:14 UTC (rev 53556)
+++ trunk/tests/phpunit/tests/post/slashes.php 2022-06-23 14:24:08 UTC (rev 53557)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6,6 +6,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 21767
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_Post_Slashes extends WP_UnitTestCase {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /*
+ * It is important to test with both even and odd numbered slashes,
+ * as KSES does a strip-then-add slashes in some of its function calls.
+ */
+
+ const SLASH_1 = 'String with 1 slash \\';
+ const SLASH_2 = 'String with 2 slashes \\\\';
+ const SLASH_3 = 'String with 3 slashes \\\\\\';
+ const SLASH_4 = 'String with 4 slashes \\\\\\\\';
+ const SLASH_5 = 'String with 5 slashes \\\\\\\\\\';
+ const SLASH_6 = 'String with 6 slashes \\\\\\\\\\\\';
+ const SLASH_7 = 'String with 7 slashes \\\\\\\\\\\\\\';
+
</ins><span class="cx" style="display: block; padding: 0 10px"> protected static $author_id;
</span><span class="cx" style="display: block; padding: 0 10px"> protected static $post_id;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -18,16 +32,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> parent::set_up();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$author_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- // It is important to test with both even and odd numbered slashes,
- // as KSES does a strip-then-add slashes in some of its function calls.
- $this->slash_1 = 'String with 1 slash \\';
- $this->slash_2 = 'String with 2 slashes \\\\';
- $this->slash_3 = 'String with 3 slashes \\\\\\';
- $this->slash_4 = 'String with 4 slashes \\\\\\\\';
- $this->slash_5 = 'String with 5 slashes \\\\\\\\\\';
- $this->slash_6 = 'String with 6 slashes \\\\\\\\\\\\';
- $this->slash_7 = 'String with 7 slashes \\\\\\\\\\\\\\';
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -38,9 +42,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST = array();
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['post_ID'] = $post_id;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $_POST['post_title'] = $this->slash_1;
- $_POST['content'] = $this->slash_5;
- $_POST['excerpt'] = $this->slash_7;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_POST['post_title'] = self::SLASH_1;
+ $_POST['content'] = self::SLASH_5;
+ $_POST['excerpt'] = self::SLASH_7;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST = add_magic_quotes( $_POST ); // The edit_post() function will strip slashes.
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -47,15 +51,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = edit_post();
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $this->slash_1, $post->post_title );
- $this->assertSame( $this->slash_5, $post->post_content );
- $this->assertSame( $this->slash_7, $post->post_excerpt );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( self::SLASH_1, $post->post_title );
+ $this->assertSame( self::SLASH_5, $post->post_content );
+ $this->assertSame( self::SLASH_7, $post->post_excerpt );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST = array();
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['post_ID'] = $post_id;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $_POST['post_title'] = $this->slash_2;
- $_POST['content'] = $this->slash_4;
- $_POST['excerpt'] = $this->slash_6;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_POST['post_title'] = self::SLASH_2;
+ $_POST['content'] = self::SLASH_4;
+ $_POST['excerpt'] = self::SLASH_6;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST = add_magic_quotes( $_POST ); // The edit_post() function will strip slashes.
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -62,9 +66,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = edit_post();
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $this->slash_2, $post->post_title );
- $this->assertSame( $this->slash_4, $post->post_content );
- $this->assertSame( $this->slash_6, $post->post_excerpt );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( self::SLASH_2, $post->post_title );
+ $this->assertSame( self::SLASH_4, $post->post_content );
+ $this->assertSame( self::SLASH_6, $post->post_excerpt );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -74,9 +78,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = wp_insert_post(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'publish',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_title' => $this->slash_1,
- 'post_content' => $this->slash_3,
- 'post_excerpt' => $this->slash_5,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_title' => self::SLASH_1,
+ 'post_content' => self::SLASH_3,
+ 'post_excerpt' => self::SLASH_5,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_type' => 'post',
</span><span class="cx" style="display: block; padding: 0 10px"> 'slashed' => false,
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -83,24 +87,24 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_1 ), $post->post_title );
- $this->assertSame( wp_unslash( $this->slash_3 ), $post->post_content );
- $this->assertSame( wp_unslash( $this->slash_5 ), $post->post_excerpt );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_1 ), $post->post_title );
+ $this->assertSame( wp_unslash( self::SLASH_3 ), $post->post_content );
+ $this->assertSame( wp_unslash( self::SLASH_5 ), $post->post_excerpt );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = wp_insert_post(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'publish',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_title' => $this->slash_2,
- 'post_content' => $this->slash_4,
- 'post_excerpt' => $this->slash_6,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_title' => self::SLASH_2,
+ 'post_content' => self::SLASH_4,
+ 'post_excerpt' => self::SLASH_6,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_type' => 'post',
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_2 ), $post->post_title );
- $this->assertSame( wp_unslash( $this->slash_4 ), $post->post_content );
- $this->assertSame( wp_unslash( $this->slash_6 ), $post->post_excerpt );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_2 ), $post->post_title );
+ $this->assertSame( wp_unslash( self::SLASH_4 ), $post->post_content );
+ $this->assertSame( wp_unslash( self::SLASH_6 ), $post->post_excerpt );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -112,30 +116,30 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_update_post(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'ID' => $post_id,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_title' => $this->slash_1,
- 'post_content' => $this->slash_3,
- 'post_excerpt' => $this->slash_5,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_title' => self::SLASH_1,
+ 'post_content' => self::SLASH_3,
+ 'post_excerpt' => self::SLASH_5,
</ins><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_1 ), $post->post_title );
- $this->assertSame( wp_unslash( $this->slash_3 ), $post->post_content );
- $this->assertSame( wp_unslash( $this->slash_5 ), $post->post_excerpt );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_1 ), $post->post_title );
+ $this->assertSame( wp_unslash( self::SLASH_3 ), $post->post_content );
+ $this->assertSame( wp_unslash( self::SLASH_5 ), $post->post_excerpt );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_update_post(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'ID' => $post_id,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_title' => $this->slash_2,
- 'post_content' => $this->slash_4,
- 'post_excerpt' => $this->slash_6,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_title' => self::SLASH_2,
+ 'post_content' => self::SLASH_4,
+ 'post_excerpt' => self::SLASH_6,
</ins><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_2 ), $post->post_title );
- $this->assertSame( wp_unslash( $this->slash_4 ), $post->post_content );
- $this->assertSame( wp_unslash( $this->slash_6 ), $post->post_excerpt );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_2 ), $post->post_title );
+ $this->assertSame( wp_unslash( self::SLASH_4 ), $post->post_content );
+ $this->assertSame( wp_unslash( self::SLASH_6 ), $post->post_excerpt );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -143,9 +147,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_wp_trash_untrash() {
</span><span class="cx" style="display: block; padding: 0 10px"> $post = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_title' => $this->slash_1,
- 'post_content' => $this->slash_3,
- 'post_excerpt' => $this->slash_5,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_title' => self::SLASH_1,
+ 'post_content' => self::SLASH_3,
+ 'post_excerpt' => self::SLASH_5,
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id = wp_insert_post( wp_slash( $post ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -154,9 +158,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $this->slash_1, $post->post_title );
- $this->assertSame( $this->slash_3, $post->post_content );
- $this->assertSame( $this->slash_5, $post->post_excerpt );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( self::SLASH_1, $post->post_title );
+ $this->assertSame( self::SLASH_3, $post->post_content );
+ $this->assertSame( self::SLASH_5, $post->post_excerpt );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $untrashed = wp_untrash_post( $post_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotEmpty( $untrashed );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -163,8 +167,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post = get_post( $post_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $this->slash_1, $post->post_title );
- $this->assertSame( $this->slash_3, $post->post_content );
- $this->assertSame( $this->slash_5, $post->post_excerpt );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( self::SLASH_1, $post->post_title );
+ $this->assertSame( self::SLASH_3, $post->post_content );
+ $this->assertSame( self::SLASH_5, $post->post_excerpt );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunitteststermslashesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/term/slashes.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/term/slashes.php 2022-06-22 16:50:14 UTC (rev 53556)
+++ trunk/tests/phpunit/tests/term/slashes.php 2022-06-23 14:24:08 UTC (rev 53557)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6,6 +6,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 21767
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_Term_Slashes extends WP_Ajax_UnitTestCase {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /*
+ * It is important to test with both even and odd numbered slashes,
+ * as KSES does a strip-then-add slashes in some of its function calls.
+ */
+
+ const SLASH_1 = 'String with 1 slash \\';
+ const SLASH_2 = 'String with 2 slashes \\\\';
+ const SLASH_3 = 'String with 3 slashes \\\\\\';
+ const SLASH_4 = 'String with 4 slashes \\\\\\\\';
+ const SLASH_5 = 'String with 5 slashes \\\\\\\\\\';
+ const SLASH_6 = 'String with 6 slashes \\\\\\\\\\\\';
+ const SLASH_7 = 'String with 7 slashes \\\\\\\\\\\\\\';
+
</ins><span class="cx" style="display: block; padding: 0 10px"> protected static $author_id;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -16,14 +30,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> parent::set_up();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$author_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- $this->slash_1 = 'String with 1 slash \\';
- $this->slash_2 = 'String with 2 slashes \\\\';
- $this->slash_3 = 'String with 3 slashes \\\\\\';
- $this->slash_4 = 'String with 4 slashes \\\\\\\\';
- $this->slash_5 = 'String with 5 slashes \\\\\\\\\\';
- $this->slash_6 = 'String with 6 slashes \\\\\\\\\\\\';
- $this->slash_7 = 'String with 7 slashes \\\\\\\\\\\\\\';
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -36,40 +42,40 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $taxonomies as $taxonomy ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $insert = wp_insert_term(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->slash_1,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::SLASH_1,
</ins><span class="cx" style="display: block; padding: 0 10px"> $taxonomy,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'slug' => 'slash_test_1_' . $taxonomy,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'description' => $this->slash_3,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'description' => self::SLASH_3,
</ins><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $term = get_term( $insert['term_id'], $taxonomy );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_1 ), $term->name );
- $this->assertSame( wp_unslash( $this->slash_3 ), $term->description );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_1 ), $term->name );
+ $this->assertSame( wp_unslash( self::SLASH_3 ), $term->description );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $insert = wp_insert_term(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->slash_3,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::SLASH_3,
</ins><span class="cx" style="display: block; padding: 0 10px"> $taxonomy,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'slug' => 'slash_test_2_' . $taxonomy,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'description' => $this->slash_5,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'description' => self::SLASH_5,
</ins><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $term = get_term( $insert['term_id'], $taxonomy );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_3 ), $term->name );
- $this->assertSame( wp_unslash( $this->slash_5 ), $term->description );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_3 ), $term->name );
+ $this->assertSame( wp_unslash( self::SLASH_5 ), $term->description );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $insert = wp_insert_term(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->slash_2,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::SLASH_2,
</ins><span class="cx" style="display: block; padding: 0 10px"> $taxonomy,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'slug' => 'slash_test_3_' . $taxonomy,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'description' => $this->slash_4,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'description' => self::SLASH_4,
</ins><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $term = get_term( $insert['term_id'], $taxonomy );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_2 ), $term->name );
- $this->assertSame( wp_unslash( $this->slash_4 ), $term->description );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_2 ), $term->name );
+ $this->assertSame( wp_unslash( self::SLASH_4 ), $term->description );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -92,38 +98,38 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $term_id,
</span><span class="cx" style="display: block; padding: 0 10px"> $taxonomy,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'name' => $this->slash_1,
- 'description' => $this->slash_3,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'name' => self::SLASH_1,
+ 'description' => self::SLASH_3,
</ins><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $term = get_term( $term_id, $taxonomy );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_1 ), $term->name );
- $this->assertSame( wp_unslash( $this->slash_3 ), $term->description );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_1 ), $term->name );
+ $this->assertSame( wp_unslash( self::SLASH_3 ), $term->description );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $update = wp_update_term(
</span><span class="cx" style="display: block; padding: 0 10px"> $term_id,
</span><span class="cx" style="display: block; padding: 0 10px"> $taxonomy,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'name' => $this->slash_3,
- 'description' => $this->slash_5,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'name' => self::SLASH_3,
+ 'description' => self::SLASH_5,
</ins><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $term = get_term( $term_id, $taxonomy );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_3 ), $term->name );
- $this->assertSame( wp_unslash( $this->slash_5 ), $term->description );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_3 ), $term->name );
+ $this->assertSame( wp_unslash( self::SLASH_5 ), $term->description );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $update = wp_update_term(
</span><span class="cx" style="display: block; padding: 0 10px"> $term_id,
</span><span class="cx" style="display: block; padding: 0 10px"> $taxonomy,
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'name' => $this->slash_2,
- 'description' => $this->slash_4,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'name' => self::SLASH_2,
+ 'description' => self::SLASH_4,
</ins><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $term = get_term( $term_id, $taxonomy );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_2 ), $term->name );
- $this->assertSame( wp_unslash( $this->slash_4 ), $term->description );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_2 ), $term->name );
+ $this->assertSame( wp_unslash( self::SLASH_4 ), $term->description );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsuserslashesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/user/slashes.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/user/slashes.php 2022-06-22 16:50:14 UTC (rev 53556)
+++ trunk/tests/phpunit/tests/user/slashes.php 2022-06-23 14:24:08 UTC (rev 53557)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6,6 +6,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 21767
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_User_Slashes extends WP_UnitTestCase {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /*
+ * It is important to test with both even and odd numbered slashes,
+ * as KSES does a strip-then-add slashes in some of its function calls.
+ */
+
+ const SLASH_1 = 'String with 1 slash \\';
+ const SLASH_2 = 'String with 2 slashes \\\\';
+ const SLASH_3 = 'String with 3 slashes \\\\\\';
+ const SLASH_4 = 'String with 4 slashes \\\\\\\\';
+ const SLASH_5 = 'String with 5 slashes \\\\\\\\\\';
+ const SLASH_6 = 'String with 6 slashes \\\\\\\\\\\\';
+ const SLASH_7 = 'String with 7 slashes \\\\\\\\\\\\\\';
+
</ins><span class="cx" style="display: block; padding: 0 10px"> protected static $author_id;
</span><span class="cx" style="display: block; padding: 0 10px"> protected static $user_id;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -18,16 +32,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> parent::set_up();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( self::$author_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- // It is important to test with both even and odd numbered slashes,
- // as KSES does a strip-then-add slashes in some of its function calls.
- $this->slash_1 = 'String with 1 slash \\';
- $this->slash_2 = 'String with 2 slashes \\\\';
- $this->slash_3 = 'String with 3 slashes \\\\\\';
- $this->slash_4 = 'String with 4 slashes \\\\\\\\';
- $this->slash_5 = 'String with 5 slashes \\\\\\\\\\';
- $this->slash_6 = 'String with 6 slashes \\\\\\\\\\\\';
- $this->slash_7 = 'String with 7 slashes \\\\\\\\\\\\\\';
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -42,11 +46,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['pass2'] = 'password';
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['role'] = 'subscriber';
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['email'] = 'user1@example.com';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $_POST['first_name'] = $this->slash_1;
- $_POST['last_name'] = $this->slash_3;
- $_POST['nickname'] = $this->slash_5;
- $_POST['display_name'] = $this->slash_7;
- $_POST['description'] = $this->slash_3;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_POST['first_name'] = self::SLASH_1;
+ $_POST['last_name'] = self::SLASH_3;
+ $_POST['nickname'] = self::SLASH_5;
+ $_POST['display_name'] = self::SLASH_7;
+ $_POST['description'] = self::SLASH_3;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST = add_magic_quotes( $_POST ); // The add_user() function will strip slashes.
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -53,11 +57,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $user_id = add_user();
</span><span class="cx" style="display: block; padding: 0 10px"> $user = get_user_to_edit( $user_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $this->slash_1, $user->first_name );
- $this->assertSame( $this->slash_3, $user->last_name );
- $this->assertSame( $this->slash_5, $user->nickname );
- $this->assertSame( $this->slash_7, $user->display_name );
- $this->assertSame( $this->slash_3, $user->description );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( self::SLASH_1, $user->first_name );
+ $this->assertSame( self::SLASH_3, $user->last_name );
+ $this->assertSame( self::SLASH_5, $user->nickname );
+ $this->assertSame( self::SLASH_7, $user->display_name );
+ $this->assertSame( self::SLASH_3, $user->description );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST = array();
</span><span class="cx" style="display: block; padding: 0 10px"> $_GET = array();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -67,11 +71,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['pass2'] = 'password';
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['role'] = 'subscriber';
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['email'] = 'user2@example.com';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $_POST['first_name'] = $this->slash_2;
- $_POST['last_name'] = $this->slash_4;
- $_POST['nickname'] = $this->slash_6;
- $_POST['display_name'] = $this->slash_2;
- $_POST['description'] = $this->slash_4;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_POST['first_name'] = self::SLASH_2;
+ $_POST['last_name'] = self::SLASH_4;
+ $_POST['nickname'] = self::SLASH_6;
+ $_POST['display_name'] = self::SLASH_2;
+ $_POST['description'] = self::SLASH_4;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST = add_magic_quotes( $_POST ); // The add_user() function will strip slashes.
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -78,11 +82,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $user_id = add_user();
</span><span class="cx" style="display: block; padding: 0 10px"> $user = get_user_to_edit( $user_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $this->slash_2, $user->first_name );
- $this->assertSame( $this->slash_4, $user->last_name );
- $this->assertSame( $this->slash_6, $user->nickname );
- $this->assertSame( $this->slash_2, $user->display_name );
- $this->assertSame( $this->slash_4, $user->description );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( self::SLASH_2, $user->first_name );
+ $this->assertSame( self::SLASH_4, $user->last_name );
+ $this->assertSame( self::SLASH_6, $user->nickname );
+ $this->assertSame( self::SLASH_2, $user->display_name );
+ $this->assertSame( self::SLASH_4, $user->description );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -96,11 +100,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $_REQUEST = array();
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['role'] = 'subscriber';
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['email'] = 'user1@example.com';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $_POST['first_name'] = $this->slash_1;
- $_POST['last_name'] = $this->slash_3;
- $_POST['nickname'] = $this->slash_5;
- $_POST['display_name'] = $this->slash_7;
- $_POST['description'] = $this->slash_3;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_POST['first_name'] = self::SLASH_1;
+ $_POST['last_name'] = self::SLASH_3;
+ $_POST['nickname'] = self::SLASH_5;
+ $_POST['display_name'] = self::SLASH_7;
+ $_POST['description'] = self::SLASH_3;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST = add_magic_quotes( $_POST ); // The edit_user() function will strip slashes.
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -107,11 +111,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $user_id = edit_user( $user_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $user = get_user_to_edit( $user_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $this->slash_1, $user->first_name );
- $this->assertSame( $this->slash_3, $user->last_name );
- $this->assertSame( $this->slash_5, $user->nickname );
- $this->assertSame( $this->slash_7, $user->display_name );
- $this->assertSame( $this->slash_3, $user->description );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( self::SLASH_1, $user->first_name );
+ $this->assertSame( self::SLASH_3, $user->last_name );
+ $this->assertSame( self::SLASH_5, $user->nickname );
+ $this->assertSame( self::SLASH_7, $user->display_name );
+ $this->assertSame( self::SLASH_3, $user->description );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST = array();
</span><span class="cx" style="display: block; padding: 0 10px"> $_GET = array();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -118,11 +122,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $_REQUEST = array();
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['role'] = 'subscriber';
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST['email'] = 'user2@example.com';
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $_POST['first_name'] = $this->slash_2;
- $_POST['last_name'] = $this->slash_4;
- $_POST['nickname'] = $this->slash_6;
- $_POST['display_name'] = $this->slash_2;
- $_POST['description'] = $this->slash_4;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $_POST['first_name'] = self::SLASH_2;
+ $_POST['last_name'] = self::SLASH_4;
+ $_POST['nickname'] = self::SLASH_6;
+ $_POST['display_name'] = self::SLASH_2;
+ $_POST['description'] = self::SLASH_4;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $_POST = add_magic_quotes( $_POST ); // The edit_user() function will strip slashes.
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -129,11 +133,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $user_id = edit_user( $user_id );
</span><span class="cx" style="display: block; padding: 0 10px"> $user = get_user_to_edit( $user_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $this->slash_2, $user->first_name );
- $this->assertSame( $this->slash_4, $user->last_name );
- $this->assertSame( $this->slash_6, $user->nickname );
- $this->assertSame( $this->slash_2, $user->display_name );
- $this->assertSame( $this->slash_4, $user->description );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( self::SLASH_2, $user->first_name );
+ $this->assertSame( self::SLASH_4, $user->last_name );
+ $this->assertSame( self::SLASH_6, $user->nickname );
+ $this->assertSame( self::SLASH_2, $user->display_name );
+ $this->assertSame( self::SLASH_4, $user->description );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -145,21 +149,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_login' => 'slash_example_user_3',
</span><span class="cx" style="display: block; padding: 0 10px"> 'role' => 'subscriber',
</span><span class="cx" style="display: block; padding: 0 10px"> 'email' => 'user3@example.com',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'first_name' => $this->slash_1,
- 'last_name' => $this->slash_3,
- 'nickname' => $this->slash_5,
- 'display_name' => $this->slash_7,
- 'description' => $this->slash_3,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'first_name' => self::SLASH_1,
+ 'last_name' => self::SLASH_3,
+ 'nickname' => self::SLASH_5,
+ 'display_name' => self::SLASH_7,
+ 'description' => self::SLASH_3,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'user_pass' => '',
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $user = get_user_to_edit( $user_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_1 ), $user->first_name );
- $this->assertSame( wp_unslash( $this->slash_3 ), $user->last_name );
- $this->assertSame( wp_unslash( $this->slash_5 ), $user->nickname );
- $this->assertSame( wp_unslash( $this->slash_7 ), $user->display_name );
- $this->assertSame( wp_unslash( $this->slash_3 ), $user->description );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_1 ), $user->first_name );
+ $this->assertSame( wp_unslash( self::SLASH_3 ), $user->last_name );
+ $this->assertSame( wp_unslash( self::SLASH_5 ), $user->nickname );
+ $this->assertSame( wp_unslash( self::SLASH_7 ), $user->display_name );
+ $this->assertSame( wp_unslash( self::SLASH_3 ), $user->description );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $user_id = wp_insert_user(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -166,21 +170,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_login' => 'slash_example_user_4',
</span><span class="cx" style="display: block; padding: 0 10px"> 'role' => 'subscriber',
</span><span class="cx" style="display: block; padding: 0 10px"> 'email' => 'user3@example.com',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'first_name' => $this->slash_2,
- 'last_name' => $this->slash_4,
- 'nickname' => $this->slash_6,
- 'display_name' => $this->slash_2,
- 'description' => $this->slash_4,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'first_name' => self::SLASH_2,
+ 'last_name' => self::SLASH_4,
+ 'nickname' => self::SLASH_6,
+ 'display_name' => self::SLASH_2,
+ 'description' => self::SLASH_4,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'user_pass' => '',
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $user = get_user_to_edit( $user_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_2 ), $user->first_name );
- $this->assertSame( wp_unslash( $this->slash_4 ), $user->last_name );
- $this->assertSame( wp_unslash( $this->slash_6 ), $user->nickname );
- $this->assertSame( wp_unslash( $this->slash_2 ), $user->display_name );
- $this->assertSame( wp_unslash( $this->slash_4 ), $user->description );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_2 ), $user->first_name );
+ $this->assertSame( wp_unslash( self::SLASH_4 ), $user->last_name );
+ $this->assertSame( wp_unslash( self::SLASH_6 ), $user->nickname );
+ $this->assertSame( wp_unslash( self::SLASH_2 ), $user->display_name );
+ $this->assertSame( wp_unslash( self::SLASH_4 ), $user->description );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -192,39 +196,39 @@
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'ID' => $user_id,
</span><span class="cx" style="display: block; padding: 0 10px"> 'role' => 'subscriber',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'first_name' => $this->slash_1,
- 'last_name' => $this->slash_3,
- 'nickname' => $this->slash_5,
- 'display_name' => $this->slash_7,
- 'description' => $this->slash_3,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'first_name' => self::SLASH_1,
+ 'last_name' => self::SLASH_3,
+ 'nickname' => self::SLASH_5,
+ 'display_name' => self::SLASH_7,
+ 'description' => self::SLASH_3,
</ins><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $user = get_user_to_edit( $user_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_1 ), $user->first_name );
- $this->assertSame( wp_unslash( $this->slash_3 ), $user->last_name );
- $this->assertSame( wp_unslash( $this->slash_5 ), $user->nickname );
- $this->assertSame( wp_unslash( $this->slash_7 ), $user->display_name );
- $this->assertSame( wp_unslash( $this->slash_3 ), $user->description );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_1 ), $user->first_name );
+ $this->assertSame( wp_unslash( self::SLASH_3 ), $user->last_name );
+ $this->assertSame( wp_unslash( self::SLASH_5 ), $user->nickname );
+ $this->assertSame( wp_unslash( self::SLASH_7 ), $user->display_name );
+ $this->assertSame( wp_unslash( self::SLASH_3 ), $user->description );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $user_id = wp_update_user(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'ID' => $user_id,
</span><span class="cx" style="display: block; padding: 0 10px"> 'role' => 'subscriber',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'first_name' => $this->slash_2,
- 'last_name' => $this->slash_4,
- 'nickname' => $this->slash_6,
- 'display_name' => $this->slash_2,
- 'description' => $this->slash_4,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'first_name' => self::SLASH_2,
+ 'last_name' => self::SLASH_4,
+ 'nickname' => self::SLASH_6,
+ 'display_name' => self::SLASH_2,
+ 'description' => self::SLASH_4,
</ins><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $user = get_user_to_edit( $user_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( wp_unslash( $this->slash_2 ), $user->first_name );
- $this->assertSame( wp_unslash( $this->slash_4 ), $user->last_name );
- $this->assertSame( wp_unslash( $this->slash_6 ), $user->nickname );
- $this->assertSame( wp_unslash( $this->slash_2 ), $user->display_name );
- $this->assertSame( wp_unslash( $this->slash_4 ), $user->description );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSame( wp_unslash( self::SLASH_2 ), $user->first_name );
+ $this->assertSame( wp_unslash( self::SLASH_4 ), $user->last_name );
+ $this->assertSame( wp_unslash( self::SLASH_6 ), $user->nickname );
+ $this->assertSame( wp_unslash( self::SLASH_2 ), $user->display_name );
+ $this->assertSame( wp_unslash( self::SLASH_4 ), $user->description );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>
</body>
</html>