Make WordPress Core

Ticket #54273: 54273.diff

File 54273.diff, 17.1 KB (added by yagniksangani, 4 years ago)

Strict Comparison in in_array function

  • src/wp-includes/SimplePie/Cache/MySQL.php

    diff --git a/src/wp-includes/SimplePie/Cache/MySQL.php b/src/wp-includes/SimplePie/Cache/MySQL.php
    index a684eb8334..6ce275b857 100644
    a b class SimplePie_Cache_MySQL extends SimplePie_Cache_DB 
    126126                        $db[] = $row;
    127127                }
    128128
    129                 if (!in_array($this->options['extras']['prefix'] . 'cache_data', $db))
     129                if (!in_array($this->options['extras']['prefix'] . 'cache_data', $db, true))
    130130                {
    131131                        $query = $this->mysql->exec('CREATE TABLE `' . $this->options['extras']['prefix'] . 'cache_data` (`id` TEXT CHARACTER SET utf8 NOT NULL, `items` SMALLINT NOT NULL DEFAULT 0, `data` BLOB NOT NULL, `mtime` INT UNSIGNED NOT NULL, UNIQUE (`id`(125)))');
    132132                        if ($query === false)
    class SimplePie_Cache_MySQL extends SimplePie_Cache_DB 
    137137                        }
    138138                }
    139139
    140                 if (!in_array($this->options['extras']['prefix'] . 'items', $db))
     140                if (!in_array($this->options['extras']['prefix'] . 'items', $db, true))
    141141                {
    142142                        $query = $this->mysql->exec('CREATE TABLE `' . $this->options['extras']['prefix'] . 'items` (`feed_id` TEXT CHARACTER SET utf8 NOT NULL, `id` TEXT CHARACTER SET utf8 NOT NULL, `data` MEDIUMBLOB NOT NULL, `posted` INT UNSIGNED NOT NULL, INDEX `feed_id` (`feed_id`(125)))');
    143143                        if ($query === false)
  • src/wp-includes/SimplePie/Enclosure.php

    diff --git a/src/wp-includes/SimplePie/Enclosure.php b/src/wp-includes/SimplePie/Enclosure.php
    index 32216d848c..3c6298eebd 100644
    a b class SimplePie_Enclosure 
    11501150                }
    11511151
    11521152                // If we encounter an unsupported mime-type, check the file extension and guess intelligently.
    1153                 if (!in_array($type, array_merge($types_flash, $types_fmedia, $types_quicktime, $types_wmedia, $types_mp3)))
     1153                if (!in_array($type, array_merge($types_flash, $types_fmedia, $types_quicktime, $types_wmedia, $types_mp3), true))
    11541154                {
    11551155                        switch (strtolower($this->get_extension()))
    11561156                        {
    class SimplePie_Enclosure 
    12751275
    12761276                if ($find_handler)
    12771277                {
    1278                         if (in_array($type, $types_flash))
     1278                        if (in_array($type, $types_flash, true))
    12791279                        {
    12801280                                return 'flash';
    12811281                        }
    1282                         elseif (in_array($type, $types_fmedia))
     1282                        elseif (in_array($type, $types_fmedia, true))
    12831283                        {
    12841284                                return 'fmedia';
    12851285                        }
    1286                         elseif (in_array($type, $types_quicktime))
     1286                        elseif (in_array($type, $types_quicktime, true))
    12871287                        {
    12881288                                return 'quicktime';
    12891289                        }
    1290                         elseif (in_array($type, $types_wmedia))
     1290                        elseif (in_array($type, $types_wmedia, true))
    12911291                        {
    12921292                                return 'wmedia';
    12931293                        }
    1294                         elseif (in_array($type, $types_mp3))
     1294                        elseif (in_array($type, $types_mp3, true))
    12951295                        {
    12961296                                return 'mp3';
    12971297                        }
  • src/wp-includes/SimplePie/File.php

    diff --git a/src/wp-includes/SimplePie/File.php b/src/wp-includes/SimplePie/File.php
    index 90ad8196a6..c5a442e80d 100644
    a b class SimplePie_File 
    138138                                                $this->headers = $parser->headers;
    139139                                                $this->body = trim($parser->body);
    140140                                                $this->status_code = $parser->status_code;
    141                                                 if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects)
     141                                                if ((in_array($this->status_code, array(300, 301, 302, 303, 307), true) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects)
    142142                                                {
    143143                                                        $this->redirects++;
    144144                                                        $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
    class SimplePie_File 
    223223                                                        $this->headers = $parser->headers;
    224224                                                        $this->body = $parser->body;
    225225                                                        $this->status_code = $parser->status_code;
    226                                                         if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects)
     226                                                        if ((in_array($this->status_code, array(300, 301, 302, 303, 307), true) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects)
    227227                                                        {
    228228                                                                $this->redirects++;
    229229                                                                $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
  • src/wp-includes/SimplePie/Locator.php

    diff --git a/src/wp-includes/SimplePie/Locator.php b/src/wp-includes/SimplePie/Locator.php
    index a207df6fee..7aeeafbea6 100644
    a b class SimplePie_Locator 
    159159                                $mime_types[] = 'text/html';
    160160                        }
    161161
    162                         return in_array($sniffed, $mime_types);
     162                        return in_array($sniffed, $mime_types, true);
    163163                }
    164164                elseif ($file->method & SIMPLEPIE_FILE_SOURCE_LOCAL)
    165165                {
    class SimplePie_Locator 
    244244                                        continue;
    245245                                }
    246246
    247                                 if (!in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && !in_array('stylesheet', $rel) && $link->hasAttribute('type') && in_array(strtolower($this->registry->call('Misc', 'parse_mime', array($link->getAttribute('type')))), array('text/html', 'application/rss+xml', 'application/atom+xml'))) && !isset($feeds[$href]))
     247                                if (!in_array($href, $done, true) && in_array('feed', $rel, true) || (in_array('alternate', $rel, true) && !in_array('stylesheet', $rel, true) && $link->hasAttribute('type') && in_array(strtolower($this->registry->call('Misc', 'parse_mime', array($link->getAttribute('type')))), array('text/html', 'application/rss+xml', 'application/atom+xml'), true)) && !isset($feeds[$href]))
    248248                                {
    249249                                        $this->checked_feeds++;
    250250                                        $headers = array(
    class SimplePie_Locator 
    356356                                        return null;
    357357                                }
    358358                                $rel_values = explode(' ', strtolower($link->getAttribute('rel')));
    359                                 if (in_array($rel, $rel_values))
     359                                if (in_array($rel, $rel_values, true))
    360360                                {
    361361                                        return $href;
    362362                                }
    class SimplePie_Locator 
    373373                        {
    374374                                break;
    375375                        }
    376                         if (in_array(strtolower(strrchr($value, '.')), array('.rss', '.rdf', '.atom', '.xml')))
     376                        if (in_array(strtolower(strrchr($value, '.')), array('.rss', '.rdf', '.atom', '.xml'), true))
    377377                        {
    378378                                $this->checked_feeds++;
    379379
  • src/wp-includes/SimplePie/Misc.php

    diff --git a/src/wp-includes/SimplePie/Misc.php b/src/wp-includes/SimplePie/Misc.php
    index a52498ac76..dcfd63a451 100644
    a b class SimplePie_Misc 
    364364                }
    365365
    366366                // Check that the encoding is supported
    367                 if (!in_array($input, mb_list_encodings()))
     367                if (!in_array($input, mb_list_encodings(), true))
    368368                {
    369369                        return false;
    370370                }
    class SimplePie_Misc 
    19291929                                case 'xhtml':
    19301930                                        return SIMPLEPIE_CONSTRUCT_XHTML;
    19311931                        }
    1932                         if (in_array(substr($type, -4), array('+xml', '/xml')) || substr($type, 0, 5) === 'text/')
     1932                        if (in_array(substr($type, -4), array('+xml', '/xml'), true) || substr($type, 0, 5) === 'text/')
    19331933                        {
    19341934                                return SIMPLEPIE_CONSTRUCT_NONE;
    19351935                        }
  • src/wp-includes/SimplePie/Parser.php

    diff --git a/src/wp-includes/SimplePie/Parser.php b/src/wp-includes/SimplePie/Parser.php
    index 4efdf41a71..e9956976ee 100644
    a b class SimplePie_Parser 
    330330                        $this->datas[] =& $this->data;
    331331                        $this->data =& $this->data['child'][end($this->namespace)][end($this->element)][];
    332332                        $this->data = array('data' => '', 'attribs' => $attribs, 'xml_base' => end($this->xml_base), 'xml_base_explicit' => end($this->xml_base_explicit), 'xml_lang' => end($this->xml_lang));
    333                         if ((end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_03 && in_array(end($this->element), array('title', 'tagline', 'copyright', 'info', 'summary', 'content')) && isset($attribs['']['mode']) && $attribs['']['mode'] === 'xml')
    334                         || (end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_10 && in_array(end($this->element), array('rights', 'subtitle', 'summary', 'info', 'title', 'content')) && isset($attribs['']['type']) && $attribs['']['type'] === 'xhtml')
    335                         || (end($this->namespace) === SIMPLEPIE_NAMESPACE_RSS_20 && in_array(end($this->element), array('title')))
    336                         || (end($this->namespace) === SIMPLEPIE_NAMESPACE_RSS_090 && in_array(end($this->element), array('title')))
    337                         || (end($this->namespace) === SIMPLEPIE_NAMESPACE_RSS_10 && in_array(end($this->element), array('title'))))
     333                        if ((end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_03 && in_array(end($this->element), array('title', 'tagline', 'copyright', 'info', 'summary', 'content'), true) && isset($attribs['']['mode']) && $attribs['']['mode'] === 'xml')
     334                        || (end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_10 && in_array(end($this->element), array('rights', 'subtitle', 'summary', 'info', 'title', 'content'), true) && isset($attribs['']['type']) && $attribs['']['type'] === 'xhtml')
     335                        || (end($this->namespace) === SIMPLEPIE_NAMESPACE_RSS_20 && in_array(end($this->element), array('title'), true))
     336                        || (end($this->namespace) === SIMPLEPIE_NAMESPACE_RSS_090 && in_array(end($this->element), array('title'), true))
     337                        || (end($this->namespace) === SIMPLEPIE_NAMESPACE_RSS_10 && in_array(end($this->element), array('title'), true)))
    338338                        {
    339339                                $this->current_xhtml_construct = 0;
    340340                        }
    class SimplePie_Parser 
    358358                if ($this->current_xhtml_construct >= 0)
    359359                {
    360360                        $this->current_xhtml_construct--;
    361                         if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML && !in_array(end($this->element), array('area', 'base', 'basefont', 'br', 'col', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param')))
     361                        if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML && !in_array(end($this->element), array('area', 'base', 'basefont', 'br', 'col', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param'), true))
    362362                        {
    363363                                $this->data['data'] .= '</' . end($this->element) . '>';
    364364                        }
    class SimplePie_Parser 
    418418                $name = '';
    419419                $link = '';
    420420                // Check if h-card is set and pass that information on in the link.
    421                 if (isset($data['type']) && in_array('h-card', $data['type'])) {
     421                if (isset($data['type']) && in_array('h-card', $data['type'], true)) {
    422422                        if (isset($data['properties']['name'][0])) {
    423423                                $name = $data['properties']['name'][0];
    424424                        }
    class SimplePie_Parser 
    448448                // First look for an h-feed.
    449449                $h_feed = array();
    450450                foreach ($mf['items'] as $mf_item) {
    451                         if (in_array('h-feed', $mf_item['type'])) {
     451                        if (in_array('h-feed', $mf_item['type'], true)) {
    452452                                $h_feed = $mf_item;
    453453                                break;
    454454                        }
    455455                        // Also look for h-feed or h-entry in the children of each top level item.
    456456                        if (!isset($mf_item['children'][0]['type'])) continue;
    457                         if (in_array('h-feed', $mf_item['children'][0]['type'])) {
     457                        if (in_array('h-feed', $mf_item['children'][0]['type'], true)) {
    458458                                $h_feed = $mf_item['children'][0];
    459459                                // In this case the parent of the h-feed may be an h-card, so use it as
    460460                                // the feed_author.
    461                                 if (in_array('h-card', $mf_item['type'])) $feed_author = $mf_item;
     461                                if (in_array('h-card', $mf_item['type'], true)) $feed_author = $mf_item;
    462462                                break;
    463463                        }
    464                         else if (in_array('h-entry', $mf_item['children'][0]['type'])) {
     464                        else if (in_array('h-entry', $mf_item['children'][0]['type'], true)) {
    465465                                $entries = $mf_item['children'];
    466466                                // In this case the parent of the h-entry list may be an h-card, so use
    467467                                // it as the feed_author.
    468                                 if (in_array('h-card', $mf_item['type'])) $feed_author = $mf_item;
     468                                if (in_array('h-card', $mf_item['type'], true)) $feed_author = $mf_item;
    469469                                break;
    470470                        }
    471471                }
    class SimplePie_Parser 
    484484                }
    485485                for ($i = 0; $i < count($entries); $i++) {
    486486                        $entry = $entries[$i];
    487                         if (in_array('h-entry', $entry['type'])) {
     487                        if (in_array('h-entry', $entry['type'], true)) {
    488488                                $item = array();
    489489                                $title = '';
    490490                                $description = '';
    class SimplePie_Parser 
    520520                                                        $mf = Mf2\fetch($author);
    521521                                                        foreach ($mf['items'] as $hcard) {
    522522                                                                // Only interested in an h-card by itself in this case.
    523                                                                 if (!in_array('h-card', $hcard['type'])) {
     523                                                                if (!in_array('h-card', $hcard['type'], true)) {
    524524                                                                        continue;
    525525                                                                }
    526526                                                                // It must have a url property matching what we fetched.
    527527                                                                if (!isset($hcard['properties']['url']) ||
    528                                                                                 !(in_array($author, $hcard['properties']['url']))) {
     528                                                                                !(in_array($author, $hcard['properties']['url'], true))) {
    529529                                                                        continue;
    530530                                                                }
    531531                                                                // Save parse_hcard the trouble of finding the correct url.
  • src/wp-includes/SimplePie/Registry.php

    diff --git a/src/wp-includes/SimplePie/Registry.php b/src/wp-includes/SimplePie/Registry.php
    index bf3baf1793..a2862bf261 100644
    a b class SimplePie_Registry 
    160160        {
    161161                $class = $this->get_class($type);
    162162
    163                 if (in_array($class, $this->legacy))
     163                if (in_array($class, $this->legacy, true))
    164164                {
    165165                        switch ($type)
    166166                        {
    class SimplePie_Registry 
    202202        {
    203203                $class = $this->get_class($type);
    204204
    205                 if (in_array($class, $this->legacy))
     205                if (in_array($class, $this->legacy, true))
    206206                {
    207207                        switch ($type)
    208208                        {
  • src/wp-includes/SimplePie/Sanitize.php

    diff --git a/src/wp-includes/SimplePie/Sanitize.php b/src/wp-includes/SimplePie/Sanitize.php
    index 35838032fc..dbeefe1784 100644
    a b class SimplePie_Sanitize 
    431431                        $attributes = array($attributes);
    432432                }
    433433
    434                 if (!is_array($this->strip_htmltags) || !in_array($tag, $this->strip_htmltags))
     434                if (!is_array($this->strip_htmltags) || !in_array($tag, $this->strip_htmltags, true))
    435435                {
    436436                        $elements = $document->getElementsByTagName($tag);
    437437                        foreach ($elements as $element)
    class SimplePie_Sanitize 
    455455        {
    456456                if ($this->encode_instead_of_strip)
    457457                {
    458                         if (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style')))
     458                        if (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style'), true))
    459459                        {
    460460                                $match[1] = htmlspecialchars($match[1], ENT_COMPAT, 'UTF-8');
    461461                                $match[2] = htmlspecialchars($match[2], ENT_COMPAT, 'UTF-8');
    class SimplePie_Sanitize 
    466466                                return htmlspecialchars($match[0], ENT_COMPAT, 'UTF-8');
    467467                        }
    468468                }
    469                 elseif (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style')))
     469                elseif (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style'), true))
    470470                {
    471471                        return $match[4];
    472472                }
    class SimplePie_Sanitize 
    486486                                $fragment = $document->createDocumentFragment();
    487487
    488488                                // For elements which aren't script or style, include the tag itself
    489                                 if (!in_array($tag, array('script', 'style')))
     489                                if (!in_array($tag, array('script', 'style'), true))
    490490                                {
    491491                                        $text = '<' . $tag;
    492492                                        if ($element->hasAttributes())
    class SimplePie_Sanitize 
    524524                                        $fragment->appendChild($child);
    525525                                }
    526526
    527                                 if (!in_array($tag, array('script', 'style')))
     527                                if (!in_array($tag, array('script', 'style'), true))
    528528                                {
    529529                                        $fragment->appendChild(new DOMText('</' . $tag . '>'));
    530530                                }
    class SimplePie_Sanitize 
    534534
    535535                        return;
    536536                }
    537                 elseif (in_array($tag, array('script', 'style')))
     537                elseif (in_array($tag, array('script', 'style'), true))
    538538                {
    539539                        foreach ($elements as $element)
    540540                        {
  • src/wp-includes/sodium_compat/src/Compat.php

    diff --git a/src/wp-includes/sodium_compat/src/Compat.php b/src/wp-includes/sodium_compat/src/Compat.php
    index b2ccd21ddf..70ba6d77cd 100644
    a b class ParagonIE_Sodium_Compat 
    323323            // OpenSSL isn't installed
    324324            return false;
    325325        }
    326         return (bool) in_array('aes-256-gcm', openssl_get_cipher_methods());
     326        return (bool) in_array('aes-256-gcm', openssl_get_cipher_methods(), true);
    327327    }
    328328
    329329    /**
  • src/wp-includes/sodium_compat/src/Core/Util.php

    diff --git a/src/wp-includes/sodium_compat/src/Core/Util.php b/src/wp-includes/sodium_compat/src/Core/Util.php
    index bde9df1106..262b20cec3 100644
    a b abstract class ParagonIE_Sodium_Core_Util 
    200200            case 'integer':
    201201            case 'int':
    202202                $allow = array('int', 'integer');
    203                 if (!in_array($type, $allow)) {
     203                if (!in_array($type, $allow, true)) {
    204204                    throw new TypeError('Argument ' . $argumentIndex . ' must be an integer, ' . $realType . ' given.');
    205205                }
    206206                $mixedVar = (int) $mixedVar;
    abstract class ParagonIE_Sodium_Core_Util 
    208208            case 'boolean':
    209209            case 'bool':
    210210                $allow = array('bool', 'boolean');
    211                 if (!in_array($type, $allow)) {
     211                if (!in_array($type, $allow, true)) {
    212212                    throw new TypeError('Argument ' . $argumentIndex . ' must be a boolean, ' . $realType . ' given.');
    213213                }
    214214                $mixedVar = (bool) $mixedVar;
    abstract class ParagonIE_Sodium_Core_Util 
    223223            case 'double':
    224224            case 'float':
    225225                $allow = array('decimal', 'double', 'float');
    226                 if (!in_array($type, $allow)) {
     226                if (!in_array($type, $allow, true)) {
    227227                    throw new TypeError('Argument ' . $argumentIndex . ' must be a float, ' . $realType . ' given.');
    228228                }
    229229                $mixedVar = (float) $mixedVar;