Skip to content

Commit c0cb540

Browse files
committed
Fix handling of password protected posts
1 parent 2274bd0 commit c0cb540

File tree

4 files changed

+40
-3
lines changed

4 files changed

+40
-3
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
**Tags:** OStatus, fediverse, activitypub, activitystream
55
**Requires at least:** 4.7
66
**Tested up to:** 6.1
7-
**Stable tag:** 0.16.4
7+
**Stable tag:** 0.16.5
88
**Requires PHP:** 5.6
99
**License:** MIT
1010
**License URI:** http://opensource.org/licenses/MIT
@@ -88,6 +88,10 @@ Where 'blog' is the path to the subdirectory at which your blog resides.
8888

8989
Project maintained on GitHub at [pfefferle/wordpress-activitypub](https://github.com/pfefferle/wordpress-activitypub).
9090

91+
### 0.16.5 ###
92+
93+
* Return empty content/excerpt on password protected posts/pages
94+
9195
### 0.16.4 ###
9296

9397
* Remove scripts later in the queue, to also handle scripts added by blocks

activitypub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: ActivityPub
44
* Plugin URI: https://github.com/pfefferle/wordpress-activitypub/
55
* Description: The ActivityPub protocol is a decentralized social networking protocol based upon the ActivityStreams 2.0 data format.
6-
* Version: 0.16.4
6+
* Version: 0.16.5
77
* Author: Matthias Pfefferle
88
* Author URI: https://notiz.blog/
99
* License: MIT

readme.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Donate link: https://notiz.blog/donate/
44
Tags: OStatus, fediverse, activitypub, activitystream
55
Requires at least: 4.7
66
Tested up to: 6.1
7-
Stable tag: 0.16.4
7+
Stable tag: 0.16.5
88
Requires PHP: 5.6
99
License: MIT
1010
License URI: http://opensource.org/licenses/MIT
@@ -88,6 +88,10 @@ Where 'blog' is the path to the subdirectory at which your blog resides.
8888

8989
Project maintained on GitHub at [pfefferle/wordpress-activitypub](https://github.com/pfefferle/wordpress-activitypub).
9090

91+
= 0.16.5 =
92+
93+
* Return empty content/excerpt on password protected posts/pages
94+
9195
= 0.16.4 =
9296

9397
* Remove scripts later in the queue, to also handle scripts added by blocks

tests/test-class-activitypub-shortcodes.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,33 @@ public function test_content() {
2727

2828
$this->assertEquals( '<p>hallo</p>', $content );
2929
}
30+
31+
public function test_password_protected_content() {
32+
global $post;
33+
34+
$post_id = -98; // negative ID, to avoid clash with a valid post
35+
$post = new stdClass();
36+
$post->ID = $post_id;
37+
$post->post_author = 1;
38+
$post->post_date = current_time( 'mysql' );
39+
$post->post_date_gmt = current_time( 'mysql', 1 );
40+
$post->post_title = 'Some title or other';
41+
$post->post_content = '<script>test</script>hallo<script type="javascript">{"asdf": "qwerty"}</script><style></style>';
42+
$post->post_status = 'publish';
43+
$post->comment_status = 'closed';
44+
$post->ping_status = 'closed';
45+
$post->post_name = 'fake-page-' . rand( 1, 99999 ); // append random number to avoid clash
46+
$post->post_type = 'page';
47+
$post->post_password = 'abc';
48+
$post->filter = 'raw'; // important!
49+
50+
$content = '[ap_content]';
51+
52+
// Fill in the shortcodes.
53+
setup_postdata( $post );
54+
$content = do_shortcode( $content );
55+
wp_reset_postdata();
56+
57+
$this->assertEquals( '', $content );
58+
}
3059
}

0 commit comments

Comments
 (0)