<!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>[10177] sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory: Theme Directory: API: Be far more strict and defensive with inputs.</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="http://meta.trac.wordpress.org/changeset/10177">10177</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://meta.trac.wordpress.org/changeset/10177","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>dd32</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2020-08-19 00:17:39 +0000 (Wed, 19 Aug 2020)</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'>Theme Directory: API: Be far more strict and defensive with inputs.
Someone out there is sending a lot of requests to the API with junk data causing PHP warnings.
This validates input and rejects the junk.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsthemedirectoryclassthemesapiphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/class-themes-api.php</a></li>
<li><a href="#sitestrunkwordpressorgpublic_htmlwpcontentpluginsthemedirectorythemedirectoryphp">sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsthemedirectoryclassthemesapiphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/class-themes-api.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/class-themes-api.php 2020-08-18 05:55:10 UTC (rev 10176)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/class-themes-api.php 2020-08-19 00:17:39 UTC (rev 10177)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -78,6 +78,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> private $cache_life = 600; // 10 minutes.
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Flag the input as having been malformed.
+ *
+ * @var bool
+ */
+ public $bad_input = false;
</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"> * Constructor.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -88,6 +94,41 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function __construct( $action = '', $request = array() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->request = (object) $request;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Filter out bad inputs.
+ $scalar_only_fields = [
+ 'author',
+ 'browse',
+ 'locale',
+ 'per_page',
+ 'slug',
+ 'search',
+ 'theme',
+ 'wp_version',
+ ];
+ foreach ( $scalar_only_fields as $field ) {
+ if ( isset( $this->request->$field ) && ! is_scalar( $this->request->$field ) ) {
+ unset( $this->request->$field );
+ $this->bad_input = true;
+ }
+ }
+
+ $array_of_string_fields = [
+ 'fields',
+ 'slugs',
+ 'tag',
+ ];
+ foreach ( $array_of_string_fields as $field ) {
+ if ( isset( $this->request->$field ) ) {
+ $this->request->$field = $this->array_of_strings( $this->request->$field );
+
+ // If the resulting field is invalid, ignore it entirely.
+ if ( ! $this->request->$field ) {
+ unset( $this->request->$field );
+ $this->bad_input = true;
+ }
+ }
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // The locale we should use is specified by the request
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'locale', array( $this, 'filter_locale' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -112,7 +153,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Filter get_locale() to use the locale which is specified in the request.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function filter_locale( $locale ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return isset( $this->request->locale ) ? $this->request->locale : $locale;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! empty( $this->request->locale ) ) {
+ $locale = (string) $this->request->locale;
+ }
+
+ return $locale;
</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">@@ -134,6 +179,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return wp_json_encode( $response );
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( 'php' === $format ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return serialize( $response );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } elseif ( 'api_object' === $format ) {
+ return $this;
</ins><span class="cx" style="display: block; padding: 0 10px"> } else { // 'raw' === $format, or anything else.
</span><span class="cx" style="display: block; padding: 0 10px"> return $response;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -166,7 +213,7 @@
</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"> if ( ! empty( $this->request->number ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->response = array_slice( $this->response, 0, $this->request->number );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->response = array_slice( $this->response, 0, (int) $this->request->number );
</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">@@ -236,8 +283,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // The 1.2+ api expects a `wp_version` field to be sent and does not use the UA.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( defined( 'THEMES_API_VERSION' ) && THEMES_API_VERSION >= 1.2 ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( isset( $this->request->wp_version ) ) {
- $wp_version = $this->request->wp_version;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! empty( $this->request->wp_version ) ) {
+ $wp_version = (string) $this->request->wp_version;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( preg_match( '|WordPress/([^;]+)|', $_SERVER['HTTP_USER_AGENT'], $matches ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // Get version from user agent since it's not explicitly sent to feature_list requests in older API branches.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -324,8 +371,7 @@
</span><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><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $slugs = is_array( $this->request->slugs ) ? $this->request->slugs : explode( ',', $this->request->slugs );
- $slugs = array_unique( array_map( 'trim', $slugs ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $slugs = (array) $this->request->slugs;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( count( $slugs ) > 100 ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->response = (object) array( 'error' => 'A maximum of 100 themes can be queried at once.' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -356,11 +402,13 @@
</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"> // Theme slug to identify theme.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( empty( $this->request->slug ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( empty( $this->request->slug ) || ! trim( $this->request->slug ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->response = (object) array( 'error' => 'Slug not provided' );
</span><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><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->request->slug = trim( $this->request->slug );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Set which fields wanted by default:
</span><span class="cx" style="display: block; padding: 0 10px"> $defaults = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'sections' => true,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -381,9 +429,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $defaults['requires_php'] = true;
</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 ( empty( $this->request->fields ) ) {
- $this->request->fields = array();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->request->fields = (array) $this->request->fields ?? [];
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->fields = array_merge( $this->fields, $defaults, (array) $this->request->fields );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // If there is a cached result, return that.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -447,12 +494,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $defaults['requires_php'] = true;
</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 ( isset( $this->request->fields ) ) {
- $this->fields = array_merge( $this->fields, $defaults, (array) $this->request->fields );
- } else {
- $this->fields = array_merge( $this->fields, $defaults );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->request->fields = (array) $this->request->fields ?? [];
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->fields = array_merge( $this->fields, $defaults, $this->request->fields );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // If there is a cached result, return that.
</span><span class="cx" style="display: block; padding: 0 10px"> $cache_key = sanitize_key( __METHOD__ . ':' . get_locale() . ':' . md5( serialize( $this->request ) . serialize( $this->fields ) ) );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( false !== ( $this->response = wp_cache_get( $cache_key, $this->cache_group ) ) && empty( $this->request->cache_buster ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -461,10 +506,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->result = $this->perform_wp_query();
</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 ( empty( $this->request->fields ) ) {
- $this->request->fields = array();
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> // Basic information about the request.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->response = (object) array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'info' => array(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -495,17 +536,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->query['paged'] = (int) $this->request->page;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $this->request->per_page ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->query['posts_per_page'] = min( $this->request->per_page, 999 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->query['posts_per_page'] = min( (int) $this->request->per_page, 999 );
</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"> // Views
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $this->request->browse ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->query['browse'] = $this->request->browse;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->query['browse'] = (string) $this->request->browse;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'featured' == $this->request->browse ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->cache_life = HOUR_IN_SECONDS;
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( 'favorites' == $this->request->browse ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->query['favorites_user'] = $this->request->user;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->query['favorites_user'] = (string) $this->request->user;
</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">@@ -512,10 +553,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Tags
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $this->request->tag ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! is_array( $this->request->tag ) ) {
- $this->request->tag = explode( ',', $this->request->tag );
- }
- $this->request->tag = array_unique( $this->request->tag );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->request->tag = (array) $this->request->tag;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Replace updated tags.
</span><span class="cx" style="display: block; padding: 0 10px"> $updated_tags = array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -540,12 +578,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Search
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $this->request->search ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->query['s'] = $this->request->search;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->query['s'] = (string) $this->request->search;
</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"> // Direct theme
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $this->request->theme ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->query['name'] = $this->request->theme;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->query['name'] = (string) $this->request->theme;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'parse_query', array( $this, 'direct_theme_query' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -552,7 +590,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Author
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $this->request->author ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->query['author_name'] = $this->request->author;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->query['author_name'] = (string) $this->request->author;
</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"> // Query
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -867,4 +905,28 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return $description;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * Helper method to return an array of trimmed strings.
+ */
+ protected function array_of_strings( $input ) {
+ if ( is_string( $input ) ) {
+ $input = explode( ',', $input );
+ }
+
+ if ( ! $input || ! is_array( $input ) ) {
+ return [];
+ }
+
+ foreach ( $input as $k => $v ) {
+ if ( ! is_scalar( $v ) ) {
+ unset( $input[ $k ] );
+ } elseif ( is_string( $v ) ) {
+ // Don't affect non-strings such as int's and bools.
+ $input[ $k ] = trim( $v );
+ }
+ }
+
+ return array_unique( $input );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="sitestrunkwordpressorgpublic_htmlwpcontentpluginsthemedirectorythemedirectoryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php 2020-08-18 05:55:10 UTC (rev 10176)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php 2020-08-19 00:17:39 UTC (rev 10177)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -856,7 +856,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param $method string The Method being called. Valid values: 'query_themes', 'theme_information', 'hot_tags', 'feature_list', and 'get_commercial_shops'
</span><span class="cx" style="display: block; padding: 0 10px"> * @param $args array The arguements for the call.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param $format string The format to return the data in. Valid values: 'json', 'php', 'raw' (default)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param $format string The format to return the data in. Valid values: 'json', 'php', 'api_object', 'raw' (default)
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wporg_themes_query_api( $method, $args = array(), $format = 'raw' ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! class_exists( 'Themes_API' ) ) {
</span></span></pre>
</div>
</div>
</body>
</html>