<!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>[55677] trunk/src: Coding Standards: Use strict comparison where `strtolower()` is involved.</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/55677">55677</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/55677","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>2023-04-22 15:17:47 +0000 (Sat, 22 Apr 2023)</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'>Coding Standards: Use strict comparison where `strtolower()` is involved.
Follow-up to <a href="https://core.trac.wordpress.org/changeset/649">[649]</a>, <a href="https://core.trac.wordpress.org/changeset/7736">[7736]</a>, <a href="https://core.trac.wordpress.org/changeset/18821">[18821]</a>, <a href="https://core.trac.wordpress.org/changeset/19444">[19444]</a>, <a href="https://core.trac.wordpress.org/changeset/20886">[20886]</a>, <a href="https://core.trac.wordpress.org/changeset/20893">[20893]</a>, <a href="https://core.trac.wordpress.org/changeset/23303">[23303]</a>, <a href="https://core.trac.wordpress.org/changeset/55642">[55642]</a>, <a href="https://core.trac.wordpress.org/changeset/55652">[55652]</a>, <a href="https://core.trac.wordpress.org/changeset/55653">[55653]</a>, <a href="https://core.trac.wordpress.org/changeset/55654">[55654]</a>.
Props aristath, poena, afercia, SergeyBiryukov.
See <a href="https://core.trac.wordpress.org/ticket/57839">#57839</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludesupgradephp">trunk/src/wp-admin/includes/upgrade.php</a></li>
<li><a href="#trunksrcwpincludesformattingphp">trunk/src/wp-includes/formatting.php</a></li>
<li><a href="#trunksrcwpincludesksesphp">trunk/src/wp-includes/kses.php</a></li>
<li><a href="#trunksrcwpincludespostphp">trunk/src/wp-includes/post.php</a></li>
<li><a href="#trunksrcwpincludesthemephp">trunk/src/wp-includes/theme.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludesupgradephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/upgrade.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/upgrade.php 2023-04-21 13:31:20 UTC (rev 55676)
+++ trunk/src/wp-admin/includes/upgrade.php 2023-04-22 15:17:47 UTC (rev 55677)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1739,6 +1739,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $_sidebars_widgets[ $index ][ $i ] = $id;
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $id = sanitize_title( $name );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $wp_registered_widgets[ $id ] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $_sidebars_widgets[ $index ][ $i ] = $id;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1748,13 +1749,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $found = false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $wp_registered_widgets as $widget_id => $widget ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( strtolower( $widget['name'] ) == strtolower( $name ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( strtolower( $widget['name'] ) === strtolower( $name ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $_sidebars_widgets[ $index ][ $i ] = $widget['id'];
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $found = true;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ $found = true;
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } elseif ( sanitize_title( $widget['name'] ) == sanitize_title( $name ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } elseif ( sanitize_title( $widget['name'] ) === sanitize_title( $name ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $_sidebars_widgets[ $index ][ $i ] = $widget['id'];
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $found = true;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ $found = true;
</ins><span class="cx" style="display: block; padding: 0 10px"> break;
</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="trunksrcwpincludesformattingphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/formatting.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/formatting.php 2023-04-21 13:31:20 UTC (rev 55676)
+++ trunk/src/wp-includes/formatting.php 2023-04-22 15:17:47 UTC (rev 55677)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3029,13 +3029,26 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $nested_code_pre = 0; // Keep track of how many levels link is nested inside <pre> or <code>.
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $textarr as $piece ) {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( preg_match( '|^<code[\s>]|i', $piece ) || preg_match( '|^<pre[\s>]|i', $piece ) || preg_match( '|^<script[\s>]|i', $piece ) || preg_match( '|^<style[\s>]|i', $piece ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( preg_match( '|^<code[\s>]|i', $piece )
+ || preg_match( '|^<pre[\s>]|i', $piece )
+ || preg_match( '|^<script[\s>]|i', $piece )
+ || preg_match( '|^<style[\s>]|i', $piece )
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $nested_code_pre++;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } elseif ( $nested_code_pre && ( '</code>' === strtolower( $piece ) || '</pre>' === strtolower( $piece ) || '</script>' === strtolower( $piece ) || '</style>' === strtolower( $piece ) ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } elseif ( $nested_code_pre
+ && ( '</code>' === strtolower( $piece )
+ || '</pre>' === strtolower( $piece )
+ || '</script>' === strtolower( $piece )
+ || '</style>' === strtolower( $piece )
+ )
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $nested_code_pre--;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $nested_code_pre || empty( $piece ) || ( '<' === $piece[0] && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $nested_code_pre
+ || empty( $piece )
+ || ( '<' === $piece[0] && ! preg_match( '|^<\s*[\w]{1,20}+://|', $piece ) )
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $r .= $piece;
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4463,7 +4476,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $protocols = wp_allowed_protocols();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $good_protocol_url = wp_kses_bad_protocol( $url, $protocols );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( strtolower( $good_protocol_url ) != strtolower( $url ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( strtolower( $good_protocol_url ) !== strtolower( $url ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return '';
</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="trunksrcwpincludesksesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/kses.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/kses.php 2023-04-21 13:31:20 UTC (rev 55676)
+++ trunk/src/wp-includes/kses.php 2023-04-22 15:17:47 UTC (rev 55677)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1640,7 +1640,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * If the given value is an "n" or an "N", the attribute must have a value.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( strtolower( $checkvalue ) != $vless ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( strtolower( $checkvalue ) !== $vless ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $ok = false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1846,7 +1846,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $allowed = false;
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( (array) $allowed_protocols as $one_protocol ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( strtolower( $one_protocol ) == $scheme ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( strtolower( $one_protocol ) === $scheme ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $allowed = true;
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpincludespostphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/post.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/post.php 2023-04-21 13:31:20 UTC (rev 55676)
+++ trunk/src/wp-includes/post.php 2023-04-22 15:17:47 UTC (rev 55677)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4194,7 +4194,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // On updates, we need to check to see if it's using the old, fixed sanitization context.
</span><span class="cx" style="display: block; padding: 0 10px"> $check_name = sanitize_title( $post_name, '', 'old-save' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $update && strtolower( urlencode( $post_name ) ) == $check_name && get_post_field( 'post_name', $post_id ) == $check_name ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $update
+ && strtolower( urlencode( $post_name ) ) === $check_name
+ && get_post_field( 'post_name', $post_id ) === $check_name
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $post_name = $check_name;
</span><span class="cx" style="display: block; padding: 0 10px"> } else { // New post, or slug has changed.
</span><span class="cx" style="display: block; padding: 0 10px"> $post_name = sanitize_title( $post_name );
</span></span></pre></div>
<a id="trunksrcwpincludesthemephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/theme.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/theme.php 2023-04-21 13:31:20 UTC (rev 55676)
+++ trunk/src/wp-includes/theme.php 2023-04-22 15:17:47 UTC (rev 55677)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3625,7 +3625,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function _wp_customize_loader_settings() {
</span><span class="cx" style="display: block; padding: 0 10px"> $admin_origin = parse_url( admin_url() );
</span><span class="cx" style="display: block; padding: 0 10px"> $home_origin = parse_url( home_url() );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $cross_domain = ( strtolower( $admin_origin['host'] ) != strtolower( $home_origin['host'] ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $cross_domain = ( strtolower( $admin_origin['host'] ) !== strtolower( $home_origin['host'] ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $browser = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'mobile' => wp_is_mobile(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3690,7 +3690,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_customize_support_script() {
</span><span class="cx" style="display: block; padding: 0 10px"> $admin_origin = parse_url( admin_url() );
</span><span class="cx" style="display: block; padding: 0 10px"> $home_origin = parse_url( home_url() );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $cross_domain = ( strtolower( $admin_origin['host'] ) != strtolower( $home_origin['host'] ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $cross_domain = ( strtolower( $admin_origin['host'] ) !== strtolower( $home_origin['host'] ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $type_attr = current_theme_supports( 'html5', 'script' ) ? '' : ' type="text/javascript"';
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <script<?php echo $type_attr; ?>>
</span></span></pre>
</div>
</div>
</body>
</html>