PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.7
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.7
16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 All 507 releases
← All changes | modules/seo-tools/class-jetpack-seo-titles.php +9 -0 16.2 → 16.3-a.7 View file →
@@ -308,8 +308,14 @@
308 308 * @return array The sanitized array.
309 309 */
310 310 public static function sanitize_title_formats( $title_formats ) {
311 311 foreach ( $title_formats as &$format_array ) {
312 + // The API accepts an empty string as "clear this page type"; store it as
313 + // the empty list every reader expects, and don't iterate a string.
314 + if ( ! is_array( $format_array ) ) {
315 + $format_array = array();
316 + continue;
317 + }
312 318 foreach ( $format_array as &$item ) {
313 319 if ( 'string' === $item['type'] ) {
314 320 // From `wp_strip_all_tags`, but omitting the `trim` portion since we want spacing preserved.
315 321 $item['value'] = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $item['value'] );
@@ -343,9 +349,12 @@
343 349 'groups' => array(),
344 350 'archives' => array(),
345 351 );
346 352
353 + // Sanitize the stored formats too: a page type saved as '' before this guard
354 + // existed would otherwise survive every partial save from Calypso.
347 355 $previous_formats = self::get_custom_title_formats();
356 + $previous_formats = is_array( $previous_formats ) ? self::sanitize_title_formats( $previous_formats ) : array();
348 357
349 358 $result = array_merge( $empty_formats, $previous_formats, $new_formats );
350 359
351 360 if ( update_option( self::TITLE_FORMATS_OPTION, $result ) ) {