Skip to content

Commit

Permalink
Fix accept header check and add new wpsc_accept_list filter for sites…
Browse files Browse the repository at this point in the history
… to modify that list (#33972)

* Beware of strpos = 0 when checking strings

* Add "wpsc_accept_list" filter on list of JSON accept headers

* changelog

* Updated versions, etc

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/6796258678
  • Loading branch information
donnchawp authored and matticbot committed Nov 8, 2023
1 parent 423cfd5 commit 0023492
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 15 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.10.1-alpha] - unreleased
## [1.11.0-alpha] - unreleased

This is an alpha version! The changes listed here are not final.

### Added
- Super Cache: fix "accept header" check, and add new "wpsc_accept_list" filter on JSON accept list

### Changed
- General: indicate full compatibility with the latest version of WordPress, 6.4.
- General: update WordPress version requirements to WordPress 6.2.
Expand Down Expand Up @@ -691,7 +694,7 @@ This is an alpha version! The changes listed here are not final.

Misc fixes

[1.10.1-alpha]: https://github.com/Automattic/wp-super-cache/compare/v1.10.0...v1.10.1-alpha
[1.11.0-alpha]: https://github.com/Automattic/wp-super-cache/compare/v1.10.0...v1.11.0-alpha
[1.10.0]: https://github.com/Automattic/wp-super-cache/compare/v1.9.4...v1.10.0
[1.9.4]: https://github.com/Automattic/wp-super-cache/compare/v1.9.3...v1.9.4
[1.9.3]: https://github.com/Automattic/wp-super-cache/compare/v1.9.2...v1.9.3
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@
"wp-svn-autopublish": true
},
"config": {
"autoloader-suffix": "6fe342bc02f0b440f7b3c8d8ade42286_super_cacheⓥ1_10_1_alpha"
"autoloader-suffix": "6fe342bc02f0b440f7b3c8d8ade42286_super_cacheⓥ1_11_0_alpha"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-super-cache",
"version": "1.10.1-alpha",
"version": "1.11.0-alpha",
"description": "A very fast caching engine for WordPress that produces static html files.",
"homepage": "https://jetpack.com",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit6fe342bc02f0b440f7b3c8d8ade42286_super_cache1_10_1_alpha::getLoader();
return ComposerAutoloaderInit6fe342bc02f0b440f7b3c8d8ade42286_super_cache1_11_0_alpha::getLoader();
8 changes: 4 additions & 4 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInit6fe342bc02f0b440f7b3c8d8ade42286_super_cache1_10_1_alpha
class ComposerAutoloaderInit6fe342bc02f0b440f7b3c8d8ade42286_super_cache1_11_0_alpha
{
private static $loader;

Expand All @@ -22,12 +22,12 @@ public static function getLoader()
return self::$loader;
}

spl_autoload_register(array('ComposerAutoloaderInit6fe342bc02f0b440f7b3c8d8ade42286_super_cacheⓥ1_10_1_alpha', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit6fe342bc02f0b440f7b3c8d8ade42286_super_cacheⓥ1_11_0_alpha', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit6fe342bc02f0b440f7b3c8d8ade42286_super_cacheⓥ1_10_1_alpha', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit6fe342bc02f0b440f7b3c8d8ade42286_super_cacheⓥ1_11_0_alpha', 'loadClassLoader'));

require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit6fe342bc02f0b440f7b3c8d8ade42286_super_cache1_10_1_alpha::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit6fe342bc02f0b440f7b3c8d8ade42286_super_cache1_11_0_alpha::getInitializer($loader));

$loader->setClassMapAuthoritative(true);
$loader->register(true);
Expand Down
4 changes: 2 additions & 2 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Composer\Autoload;

class ComposerStaticInit6fe342bc02f0b440f7b3c8d8ade42286_super_cache1_10_1_alpha
class ComposerStaticInit6fe342bc02f0b440f7b3c8d8ade42286_super_cache1_11_0_alpha
{
public static $classMap = array (
'Automattic\\Jetpack\\Device_Detection' => __DIR__ . '/..' . '/automattic/jetpack-device-detection/src/class-device-detection.php',
Expand All @@ -15,7 +15,7 @@ class ComposerStaticInit6fe342bc02f0b440f7b3c8d8ade42286_super_cacheⓥ1_10_1_al
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->classMap = ComposerStaticInit6fe342bc02f0b440f7b3c8d8ade42286_super_cache1_10_1_alpha::$classMap;
$loader->classMap = ComposerStaticInit6fe342bc02f0b440f7b3c8d8ade42286_super_cache1_11_0_alpha::$classMap;

}, null, ClassLoader::class);
}
Expand Down
7 changes: 4 additions & 3 deletions wp-cache-phase2.php
Original file line number Diff line number Diff line change
Expand Up @@ -509,13 +509,14 @@ function wpsc_get_accept_header() {
static $accept = 'N/A';

if ( $accept === 'N/A' ) {
$json_list = array( 'application/json', 'application/activity+json', 'application/ld+json' );
$accept_headers = apply_filters( 'wpsc_accept_headers', array( 'application/json', 'application/activity+json', 'application/ld+json' ) );
$accept_headers = array_map( 'strtolower', $accept_headers );
// phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash -- $accept is checked and set below.
$accept = isset( $_SERVER['HTTP_ACCEPT'] ) ? strtolower( filter_var( $_SERVER['HTTP_ACCEPT'] ) ) : '';

foreach ( $json_list as $header ) {
if ( strpos( $accept, $header ) ) {
foreach ( $accept_headers as $header ) {
if ( strpos( $accept, $header ) !== false ) {
$accept = 'application/json';
}
}
Expand Down
2 changes: 1 addition & 1 deletion wp-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: WP Super Cache
* Plugin URI: https://wordpress.org/plugins/wp-super-cache/
* Description: Very fast caching plugin for WordPress.
* Version: 1.10.1-alpha
* Version: 1.11.0-alpha
* Author: Automattic
* Author URI: https://automattic.com/
* License: GPL2+
Expand Down

0 comments on commit 0023492

Please sign in to comment.