You've already forked wp-fedistream
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 35ad390aeb | |||
| b592e45d58 |
24
CHANGELOG.md
24
CHANGELOG.md
@@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [0.4.8] - 2026-02-02
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **Nuclear option: NEVER apply the_content filter** - Completely removed the_content filter usage
|
||||||
|
- `get_post_data()` now ALWAYS strips shortcodes and uses raw content
|
||||||
|
- NEVER calls `apply_filters('the_content', ...)` or `get_the_excerpt()`
|
||||||
|
- FediStream posts don't need shortcode processing in their content anyway
|
||||||
|
- This guarantees no recursion through WordPress hook system
|
||||||
|
|
||||||
|
## [0.4.7] - 2026-02-02
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **Hard main template rendering lock** - Added additional protection at Plugin::render() level
|
||||||
|
- Added `$rendering_main_template` flag that completely blocks any other render calls while main template is rendering
|
||||||
|
- Reduced MAX_RENDER_DEPTH from 5 to 2 (allows one level of {% include %} but prevents deeper recursion)
|
||||||
|
- template-wrapper.php now passes `is_main_template = true` to enable the hard lock
|
||||||
|
- Any render attempt during main template rendering is immediately blocked
|
||||||
|
|
||||||
## [0.4.6] - 2026-02-02
|
## [0.4.6] - 2026-02-02
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
@@ -254,7 +274,9 @@ Initial release of WP FediStream - a WordPress plugin for streaming music over A
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
[Unreleased]: https://src.bundespruefstelle.ch/magdev/wp-fedistream/compare/v0.4.6...HEAD
|
[Unreleased]: https://src.bundespruefstelle.ch/magdev/wp-fedistream/compare/v0.4.8...HEAD
|
||||||
|
[0.4.8]: https://src.bundespruefstelle.ch/magdev/wp-fedistream/compare/v0.4.7...v0.4.8
|
||||||
|
[0.4.7]: https://src.bundespruefstelle.ch/magdev/wp-fedistream/compare/v0.4.6...v0.4.7
|
||||||
[0.4.6]: https://src.bundespruefstelle.ch/magdev/wp-fedistream/compare/v0.4.5...v0.4.6
|
[0.4.6]: https://src.bundespruefstelle.ch/magdev/wp-fedistream/compare/v0.4.5...v0.4.6
|
||||||
[0.4.5]: https://src.bundespruefstelle.ch/magdev/wp-fedistream/compare/v0.4.4...v0.4.5
|
[0.4.5]: https://src.bundespruefstelle.ch/magdev/wp-fedistream/compare/v0.4.4...v0.4.5
|
||||||
[0.4.4]: https://src.bundespruefstelle.ch/magdev/wp-fedistream/compare/v0.4.3...v0.4.4
|
[0.4.4]: https://src.bundespruefstelle.ch/magdev/wp-fedistream/compare/v0.4.3...v0.4.4
|
||||||
|
|||||||
@@ -289,31 +289,18 @@ class TemplateLoader {
|
|||||||
// Track recursion to prevent infinite loops from shortcodes in content.
|
// Track recursion to prevent infinite loops from shortcodes in content.
|
||||||
++self::$recursion_depth;
|
++self::$recursion_depth;
|
||||||
|
|
||||||
// Skip the_content filter if:
|
// ALWAYS skip the_content filter to prevent any possible recursion.
|
||||||
// 1. We're in a shortcode context (prevents recursive shortcode processing)
|
// FediStream posts don't need shortcode processing in their content.
|
||||||
// 2. We're at depth > 1 (nested data loading)
|
// This is the nuclear option but it guarantees no recursion.
|
||||||
$skip_content_filter = self::$shortcode_context_depth > 0 || self::$recursion_depth > 1;
|
$excerpt = $post->post_excerpt;
|
||||||
|
if ( empty( $excerpt ) ) {
|
||||||
// When skipping content filter, also use raw excerpt to avoid get_the_excerpt()
|
// Generate a simple excerpt without triggering the_content filter.
|
||||||
// triggering the_content filter internally when generating auto-excerpts.
|
$excerpt = wp_trim_words( wp_strip_all_tags( $post->post_content ), 55, '…' );
|
||||||
if ( $skip_content_filter ) {
|
|
||||||
$excerpt = $post->post_excerpt;
|
|
||||||
if ( empty( $excerpt ) ) {
|
|
||||||
// Generate a simple excerpt without triggering the_content filter.
|
|
||||||
$excerpt = wp_trim_words( wp_strip_all_tags( $post->post_content ), 55, '…' );
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$excerpt = get_the_excerpt( $post );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// When skipping content filter, also strip shortcodes to prevent them from
|
// Strip shortcodes and sanitize content - never apply the_content filter.
|
||||||
// being processed by anything else that might call do_shortcode on the output.
|
$content = strip_shortcodes( $post->post_content );
|
||||||
if ( $skip_content_filter ) {
|
$content = wp_kses_post( $content );
|
||||||
$content = strip_shortcodes( $post->post_content );
|
|
||||||
$content = wp_kses_post( $content );
|
|
||||||
} else {
|
|
||||||
$content = apply_filters( 'the_content', $post->post_content );
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'id' => $post->ID,
|
'id' => $post->ID,
|
||||||
|
|||||||
@@ -60,7 +60,8 @@ get_header();
|
|||||||
if ( $template_name ) {
|
if ( $template_name ) {
|
||||||
try {
|
try {
|
||||||
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||||
echo $plugin->render( $template_name, $context );
|
// Pass true for is_main_template to set the hard rendering lock.
|
||||||
|
echo $plugin->render( $template_name, $context, true );
|
||||||
} catch ( \Exception $e ) {
|
} catch ( \Exception $e ) {
|
||||||
if ( WP_DEBUG ) {
|
if ( WP_DEBUG ) {
|
||||||
echo '<div class="fedistream-error">';
|
echo '<div class="fedistream-error">';
|
||||||
|
|||||||
@@ -64,10 +64,19 @@ final class Plugin {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum allowed Twig render depth.
|
* Maximum allowed Twig render depth.
|
||||||
|
* Set to 2 to allow one level of nested includes but prevent deeper recursion.
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private const MAX_RENDER_DEPTH = 5;
|
private const MAX_RENDER_DEPTH = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flag to track if we're currently rendering the main page template.
|
||||||
|
* This is a hard lock that prevents ANY other rendering.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private static bool $rendering_main_template = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Post type instances.
|
* Post type instances.
|
||||||
@@ -856,18 +865,32 @@ final class Plugin {
|
|||||||
* @param array $context Template context variables.
|
* @param array $context Template context variables.
|
||||||
* @return string Rendered template.
|
* @return string Rendered template.
|
||||||
*/
|
*/
|
||||||
public function render( string $template, array $context = array() ): string {
|
public function render( string $template, array $context = array(), bool $is_main_template = false ): string {
|
||||||
|
// If we're already rendering the main template, block any other renders.
|
||||||
|
if ( self::$rendering_main_template && ! $is_main_template ) {
|
||||||
|
return '<!-- FediStream: blocked during main template render -->';
|
||||||
|
}
|
||||||
|
|
||||||
// Prevent infinite recursion in Twig rendering.
|
// Prevent infinite recursion in Twig rendering.
|
||||||
if ( self::$render_depth >= self::MAX_RENDER_DEPTH ) {
|
if ( self::$render_depth >= self::MAX_RENDER_DEPTH ) {
|
||||||
return '<!-- FediStream: render depth exceeded -->';
|
return '<!-- FediStream: render depth exceeded -->';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set main template lock if this is the main template.
|
||||||
|
$was_main = self::$rendering_main_template;
|
||||||
|
if ( $is_main_template ) {
|
||||||
|
self::$rendering_main_template = true;
|
||||||
|
}
|
||||||
|
|
||||||
++self::$render_depth;
|
++self::$render_depth;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$result = $this->twig->render( $template . '.twig', $context );
|
$result = $this->twig->render( $template . '.twig', $context );
|
||||||
} finally {
|
} finally {
|
||||||
--self::$render_depth;
|
--self::$render_depth;
|
||||||
|
if ( $is_main_template ) {
|
||||||
|
self::$rendering_main_template = $was_main;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* Plugin Name: WP FediStream
|
* Plugin Name: WP FediStream
|
||||||
* Plugin URI: https://src.bundespruefstelle.ch/magdev/wp-fedistream
|
* Plugin URI: https://src.bundespruefstelle.ch/magdev/wp-fedistream
|
||||||
* Description: Stream music over ActivityPub - Build your own music streaming platform for Musicians and Labels.
|
* Description: Stream music over ActivityPub - Build your own music streaming platform for Musicians and Labels.
|
||||||
* Version: 0.4.6
|
* Version: 0.4.8
|
||||||
* Requires at least: 6.4
|
* Requires at least: 6.4
|
||||||
* Requires PHP: 8.3
|
* Requires PHP: 8.3
|
||||||
* Author: Marco Graetsch
|
* Author: Marco Graetsch
|
||||||
@@ -26,7 +26,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
define( 'WP_FEDISTREAM_VERSION', '0.4.6' );
|
define( 'WP_FEDISTREAM_VERSION', '0.4.8' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin file path.
|
* Plugin file path.
|
||||||
|
|||||||
Reference in New Issue
Block a user