escape even more

This commit is contained in:
Matthias Pfefferle 2020-05-12 20:30:06 +02:00
parent 9945aa7cf8
commit 122461ab6e
14 changed files with 27 additions and 27 deletions

View file

@ -8,7 +8,7 @@ $finder = PhpCsFixer\Finder::create()
return PhpCsFixer\Config::create() return PhpCsFixer\Config::create()
->setRules([ ->setRules([
'native_function_invocation' => true, 'native_function_invocation' => ['include' => ['@all']],
'native_constant_invocation' => true, 'native_constant_invocation' => true,
]) ])
->setFinder($finder) ->setFinder($finder)

View file

@ -72,7 +72,7 @@ function init() {
return '\Activitypub\Rest\Server'; return '\Activitypub\Rest\Server';
} ); } );
} }
add_action( 'plugins_loaded', '\Activitypub\init' ); \add_action( 'plugins_loaded', '\Activitypub\init' );
/** /**
* Add rewrite rules * Add rewrite rules

View file

@ -117,7 +117,7 @@ class Activitypub {
} elseif ( 'publish' === $new_status ) { } elseif ( 'publish' === $new_status ) {
\wp_schedule_single_event( \time(), 'activitypub_send_update_activity', array( $post->ID ) ); \wp_schedule_single_event( \time(), 'activitypub_send_update_activity', array( $post->ID ) );
} elseif ( 'trash' === $new_status ) { } elseif ( 'trash' === $new_status ) {
\wp_schedule_single_event( \time(), 'activitypub_send_delete_activity', array( get_permalink( $post ) ) ); \wp_schedule_single_event( \time(), 'activitypub_send_delete_activity', array( \get_permalink( $post ) ) );
} }
} }

View file

@ -30,7 +30,7 @@ class Admin {
\add_action( 'load-' . $settings_page, array( '\Activitypub\Admin', 'add_settings_help_tab' ) ); \add_action( 'load-' . $settings_page, array( '\Activitypub\Admin', 'add_settings_help_tab' ) );
$followers_list_page = \add_users_page( \__( 'Followers', 'activitypub' ), __( 'Followers (Fediverse)', 'activitypub' ), 'read', 'activitypub-followers-list', array( '\Activitypub\Admin', 'followers_list_page' ) ); $followers_list_page = \add_users_page( \__( 'Followers', 'activitypub' ), \__( 'Followers (Fediverse)', 'activitypub' ), 'read', 'activitypub-followers-list', array( '\Activitypub\Admin', 'followers_list_page' ) );
\add_action( 'load-' . $followers_list_page, array( '\Activitypub\Admin', 'add_followers_list_help_tab' ) ); \add_action( 'load-' . $followers_list_page, array( '\Activitypub\Admin', 'add_followers_list_help_tab' ) );
} }

View file

@ -157,7 +157,7 @@ function get_inbox_by_actor( $actor ) {
return $metadata['inbox']; return $metadata['inbox'];
} }
return new \WP_Error( 'activitypub_no_inbox', __( 'No "Inbox" found', 'activitypub' ), $metadata ); return new \WP_Error( 'activitypub_no_inbox', \__( 'No "Inbox" found', 'activitypub' ), $metadata );
} }
/** /**
@ -253,13 +253,13 @@ function url_to_authorid( $url ) {
global $wp_rewrite; global $wp_rewrite;
// check if url hase the same host // check if url hase the same host
if ( wp_parse_url( site_url(), \PHP_URL_HOST ) !== wp_parse_url( $url, \PHP_URL_HOST ) ) { if ( \wp_parse_url( \site_url(), \PHP_URL_HOST ) !== \wp_parse_url( $url, \PHP_URL_HOST ) ) {
return 0; return 0;
} }
// first, check to see if there is a 'author=N' to match against // first, check to see if there is a 'author=N' to match against
if ( \preg_match( '/[?&]author=(\d+)/i', $url, $values ) ) { if ( \preg_match( '/[?&]author=(\d+)/i', $url, $values ) ) {
$id = absint( $values[1] ); $id = \absint( $values[1] );
if ( $id ) { if ( $id ) {
return $id; return $id;
} }
@ -279,7 +279,7 @@ function url_to_authorid( $url ) {
// match the rewrite rule with the passed url // match the rewrite rule with the passed url
if ( \preg_match( '/https?:\/\/(.+)' . \preg_quote( $author_regexp, '/' ) . '([^\/]+)/i', $url, $match ) ) { if ( \preg_match( '/https?:\/\/(.+)' . \preg_quote( $author_regexp, '/' ) . '([^\/]+)/i', $url, $match ) ) {
$user = get_user_by( 'slug', $match[2] ); $user = \get_user_by( 'slug', $match[2] );
if ( $user ) { if ( $user ) {
return $user->ID; return $user->ID;
} }

View file

@ -105,7 +105,7 @@ class Nodeinfo {
$nodeinfo['version'] = '1.0'; $nodeinfo['version'] = '1.0';
$nodeinfo['server'] = array( $nodeinfo['server'] = array(
'baseUrl' => home_url( '/' ), 'baseUrl' => \home_url( '/' ),
'name' => \get_bloginfo( 'name' ), 'name' => \get_bloginfo( 'name' ),
'software' => 'wordpress', 'software' => 'wordpress',
'version' => \get_bloginfo( 'version' ), 'version' => \get_bloginfo( 'version' ),

View file

@ -42,7 +42,7 @@ class Outbox {
$author = \get_user_by( 'ID', $user_id ); $author = \get_user_by( 'ID', $user_id );
if ( ! $author ) { if ( ! $author ) {
return new \WP_Error( 'rest_invalid_param', __( 'User not found', 'activitypub' ), array( return new \WP_Error( 'rest_invalid_param', \__( 'User not found', 'activitypub' ), array(
'status' => 404, 'status' => 404,
'params' => array( 'params' => array(
'user_id' => \__( 'User not found', 'activitypub' ), 'user_id' => \__( 'User not found', 'activitypub' ),

View file

@ -24,7 +24,7 @@ class Server extends \WP_REST_Server {
} }
// make request filterable // make request filterable
$request = apply_filters( 'activitypub_pre_dispatch_request', $request ); $request = \apply_filters( 'activitypub_pre_dispatch_request', $request );
return parent::dispatch( $request ); return parent::dispatch( $request );
} }

View file

@ -31,7 +31,7 @@ $json->outbox = \get_rest_url( null, "/activitypub/1.0/users/$author_id/outbox"
$json->followers = \get_rest_url( null, "/activitypub/1.0/users/$author_id/followers" ); $json->followers = \get_rest_url( null, "/activitypub/1.0/users/$author_id/followers" );
$json->following = \get_rest_url( null, "/activitypub/1.0/users/$author_id/following" ); $json->following = \get_rest_url( null, "/activitypub/1.0/users/$author_id/following" );
$json->manuallyApprovesFollowers = \apply_filters( 'activitypub_json_manually_approves_followers', __return_false() ); // phpcs:ignore $json->manuallyApprovesFollowers = \apply_filters( 'activitypub_json_manually_approves_followers', \__return_false() ); // phpcs:ignore
// phpcs:ignore // phpcs:ignore
$json->publicKey = array( $json->publicKey = array(
@ -45,7 +45,7 @@ $json->attachment = array();
$json->attachment[] = array( $json->attachment[] = array(
'type' => 'PropertyValue', 'type' => 'PropertyValue',
'name' => __( 'Blog', 'activitypub' ), 'name' => \__( 'Blog', 'activitypub' ),
'value' => \html_entity_decode( 'value' => \html_entity_decode(
'<a rel="me" title="' . \esc_attr( \home_url( '/' ) ) . '" target="_blank" href="' . \home_url( '/' ) . '">' . \wp_parse_url( \home_url( '/' ), \PHP_URL_HOST ) . '</a>', '<a rel="me" title="' . \esc_attr( \home_url( '/' ) ) . '" target="_blank" href="' . \home_url( '/' ) . '">' . \wp_parse_url( \home_url( '/' ), \PHP_URL_HOST ) . '</a>',
\ENT_QUOTES, \ENT_QUOTES,
@ -55,7 +55,7 @@ $json->attachment[] = array(
$json->attachment[] = array( $json->attachment[] = array(
'type' => 'PropertyValue', 'type' => 'PropertyValue',
'name' => __( 'Profile', 'activitypub' ), 'name' => \__( 'Profile', 'activitypub' ),
'value' => \html_entity_decode( 'value' => \html_entity_decode(
'<a rel="me" title="' . \esc_attr( \get_author_posts_url( $author_id ) ) . '" target="_blank" href="' . \get_author_posts_url( $author_id ) . '">' . \wp_parse_url( \get_author_posts_url( $author_id ), \PHP_URL_HOST ) . '</a>', '<a rel="me" title="' . \esc_attr( \get_author_posts_url( $author_id ) ) . '" target="_blank" href="' . \get_author_posts_url( $author_id ) . '">' . \wp_parse_url( \get_author_posts_url( $author_id ), \PHP_URL_HOST ) . '</a>',
\ENT_QUOTES, \ENT_QUOTES,
@ -66,7 +66,7 @@ $json->attachment[] = array(
if ( \get_the_author_meta( 'user_url', $author_id ) ) { if ( \get_the_author_meta( 'user_url', $author_id ) ) {
$json->attachment[] = array( $json->attachment[] = array(
'type' => 'PropertyValue', 'type' => 'PropertyValue',
'name' => __( 'Website', 'activitypub' ), 'name' => \__( 'Website', 'activitypub' ),
'value' => \html_entity_decode( 'value' => \html_entity_decode(
'<a rel="me" title="' . \esc_attr( \get_the_author_meta( 'user_url', $author_id ) ) . '" target="_blank" href="' . \get_the_author_meta( 'user_url', $author_id ) . '">' . \wp_parse_url( \get_the_author_meta( 'user_url', $author_id ), \PHP_URL_HOST ) . '</a>', '<a rel="me" title="' . \esc_attr( \get_the_author_meta( 'user_url', $author_id ) ) . '" target="_blank" href="' . \get_the_author_meta( 'user_url', $author_id ) . '">' . \wp_parse_url( \get_the_author_meta( 'user_url', $author_id ), \PHP_URL_HOST ) . '</a>',
\ENT_QUOTES, \ENT_QUOTES,

View file

@ -14,7 +14,7 @@
<tbody> <tbody>
<tr> <tr>
<th scope="row"> <th scope="row">
<?php esc_html_e( 'Post-Content', 'activitypub' ); ?> <?php \esc_html_e( 'Post-Content', 'activitypub' ); ?>
</th> </th>
<td> <td>
<p> <p>
@ -34,7 +34,7 @@
</th> </th>
<td> <td>
<p><label><input type="checkbox" name="activitypub_use_shortlink" id="activitypub_use_shortlink" value="1" <?php echo \checked( '1', \get_option( 'activitypub_use_shortlink', '0' ) ); ?> /> <?php \esc_html_e( 'Use the Shortlink instead of the permalink', 'activitypub' ); ?></label></p> <p><label><input type="checkbox" name="activitypub_use_shortlink" id="activitypub_use_shortlink" value="1" <?php echo \checked( '1', \get_option( 'activitypub_use_shortlink', '0' ) ); ?> /> <?php \esc_html_e( 'Use the Shortlink instead of the permalink', 'activitypub' ); ?></label></p>
<p class="description"><?php \printf( esc_html( 'I can recommend %sHum%s, to prettify the Shortlinks', 'activitypub' ), '<a href="https://wordpress.org/plugins/hum/" target="_blank">', '</a>' ); ?></p> <p class="description"><?php \printf( \esc_html( 'I can recommend %sHum%s, to prettify the Shortlinks', 'activitypub' ), '<a href="https://wordpress.org/plugins/hum/" target="_blank">', '</a>' ); ?></p>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -121,6 +121,6 @@
</form> </form>
<p> <p>
<small><?php _e( 'If you like this plugin, what about a small <a href="https://notiz.blog/donate">donation</a>?', 'activitypub' ); ?></small> <small><?php \_e( 'If you like this plugin, what about a small <a href="https://notiz.blog/donate">donation</a>?', 'activitypub' ); ?></small>
</p> </p>
</div> </div>

View file

@ -14,7 +14,7 @@ require_once $_tests_dir . '/includes/functions.php';
function _manually_load_plugin() { function _manually_load_plugin() {
require \dirname( \dirname( __FILE__ ) ) . '/activitypub.php'; require \dirname( \dirname( __FILE__ ) ) . '/activitypub.php';
} }
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); \tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
require $_tests_dir . '/includes/bootstrap.php'; require $_tests_dir . '/includes/bootstrap.php';

View file

@ -10,9 +10,9 @@ class Test_Activitypub_Hashtag extends WP_UnitTestCase {
} }
public function the_content_provider() { public function the_content_provider() {
wp_create_term( 'object', 'post_tag' ); \wp_create_term( 'object', 'post_tag' );
$object = get_term_by( 'name', 'object', 'post_tag' ); $object = \get_term_by( 'name', 'object', 'post_tag' );
$link = get_term_link( $object, 'post_tag' ); $link = \get_term_link( $object, 'post_tag' );
return array( return array(
array( 'test', 'test' ), array( 'test', 'test' ),

View file

@ -1,10 +1,10 @@
<?php <?php
class Test_Activitypub extends WP_UnitTestCase { class Test_Activitypub extends WP_UnitTestCase {
public function test_post_type_support() { public function test_post_type_support() {
add_post_type_support( 'post', 'activitypub' ); \add_post_type_support( 'post', 'activitypub' );
add_post_type_support( 'page', 'activitypub' ); \add_post_type_support( 'page', 'activitypub' );
$this->assertContains( 'post', get_post_types_by_support( 'activitypub' ) ); $this->assertContains( 'post', \get_post_types_by_support( 'activitypub' ) );
$this->assertContains( 'page', get_post_types_by_support( 'activitypub' ) ); $this->assertContains( 'page', \get_post_types_by_support( 'activitypub' ) );
} }
} }

View file

@ -7,7 +7,7 @@ class Test_Db_Activitypub_Followers extends WP_UnitTestCase {
'id' => 'http://sally.example.org', 'id' => 'http://sally.example.org',
'name' => 'Sally Smith', 'name' => 'Sally Smith',
); );
update_user_meta( 1, 'activitypub_followers', $followers ); \update_user_meta( 1, 'activitypub_followers', $followers );
$db_followers = \Activitypub\Peer\Followers::get_followers( 1 ); $db_followers = \Activitypub\Peer\Followers::get_followers( 1 );