diff --git a/docker-compose-test.yml b/docker-compose-test.yml index a293823..4c69e44 100644 --- a/docker-compose-test.yml +++ b/docker-compose-test.yml @@ -1,6 +1,7 @@ version: '2' services: test-db: + platform: linux/x86_64 image: mysql:5.7 environment: MYSQL_DATABASE: activitypub-test diff --git a/includes/class-shortcodes.php b/includes/class-shortcodes.php index 7ea67b1..ad2efe5 100644 --- a/includes/class-shortcodes.php +++ b/includes/class-shortcodes.php @@ -208,6 +208,8 @@ class Shortcodes { $content = wp_filter_content_tags( $content ); } + $content = \trim( \preg_replace( '/[\n\r\t]/', '', $content ) ); + return $content; } diff --git a/includes/model/class-post.php b/includes/model/class-post.php index b224b82..a431287 100644 --- a/includes/model/class-post.php +++ b/includes/model/class-post.php @@ -387,9 +387,7 @@ class Post { $content = \wpautop( \wp_kses( $content, $this->allowed_tags ) ); $filtered_content = \apply_filters( 'activitypub_the_content', $content, $post ); - $decoded_content = \html_entity_decode( $filtered_content, \ENT_QUOTES, 'UTF-8' ); - - $content = \trim( \preg_replace( '/[\n\r\t]/', '', $content ) ); + $content = \html_entity_decode( $filtered_content, \ENT_QUOTES, 'UTF-8' ); $this->content = $content; diff --git a/tests/test-class-activitypub-rest-inbox.php b/tests/test-class-activitypub-rest-inbox.php new file mode 100644 index 0000000..58f16f3 --- /dev/null +++ b/tests/test-class-activitypub-rest-inbox.php @@ -0,0 +1,75 @@ +assertEquals( $check, Activitypub\Rest\Inbox::is_activity_public( $data ) ); + } + + public function the_data_provider() { + return array( + array( + array( + 'cc' => array( + 'https://example.org/@test', + 'https://example.com/@test2', + ), + 'to' => 'https://www.w3.org/ns/activitystreams#Public', + 'object' => array(), + ), + true, + ), + array( + array( + 'cc' => array( + 'https://example.org/@test', + 'https://example.com/@test2', + ), + 'to' => array( + 'https://www.w3.org/ns/activitystreams#Public', + ), + 'object' => array(), + ), + true, + ), + array( + array( + 'cc' => array( + 'https://example.org/@test', + 'https://example.com/@test2', + ), + 'object' => array(), + ), + false, + ), + array( + array( + 'cc' => array( + 'https://example.org/@test', + 'https://example.com/@test2', + ), + 'object' => array( + 'to' => 'https://www.w3.org/ns/activitystreams#Public', + ), + ), + true, + ), + array( + array( + 'cc' => array( + 'https://example.org/@test', + 'https://example.com/@test2', + ), + 'object' => array( + 'to' => array( + 'https://www.w3.org/ns/activitystreams#Public', + ), + ), + ), + true, + ), + ); + } +} diff --git a/tests/test-class-activitypub-shortcodes.php b/tests/test-class-activitypub-shortcodes.php new file mode 100644 index 0000000..ac97910 --- /dev/null +++ b/tests/test-class-activitypub-shortcodes.php @@ -0,0 +1,30 @@ +ID = $post_id; + $post->post_author = 1; + $post->post_date = current_time( 'mysql' ); + $post->post_date_gmt = current_time( 'mysql', 1 ); + $post->post_title = 'Some title or other'; + $post->post_content = 'hallo'; + $post->post_status = 'publish'; + $post->comment_status = 'closed'; + $post->ping_status = 'closed'; + $post->post_name = 'fake-page-' . rand( 1, 99999 ); // append random number to avoid clash + $post->post_type = 'page'; + $post->filter = 'raw'; // important! + + $content = '[ap_content]'; + + // Fill in the shortcodes. + setup_postdata( $post ); + $content = do_shortcode( $content ); + wp_reset_postdata(); + + $this->assertEquals( '

hallo

', $content ); + } +}