better json encoding
This commit is contained in:
parent
fdad48ef74
commit
ebe2d434c6
8 changed files with 29 additions and 21 deletions
|
@ -4,7 +4,7 @@
|
||||||
**Tags:** OStatus, fediverse, activitypub, activitystream
|
**Tags:** OStatus, fediverse, activitypub, activitystream
|
||||||
**Requires at least:** 4.7
|
**Requires at least:** 4.7
|
||||||
**Tested up to:** 5.1.0
|
**Tested up to:** 5.1.0
|
||||||
**Stable tag:** 0.3.0
|
**Stable tag:** 0.3.1
|
||||||
**Requires PHP:** 5.6
|
**Requires PHP:** 5.6
|
||||||
**License:** MIT
|
**License:** MIT
|
||||||
**License URI:** http://opensource.org/licenses/MIT
|
**License URI:** http://opensource.org/licenses/MIT
|
||||||
|
@ -55,6 +55,10 @@ To implement:
|
||||||
|
|
||||||
Project maintained on github at [pfefferle/wordpress-activitypub](https://github.com/pfefferle/wordpress-activitypub).
|
Project maintained on github at [pfefferle/wordpress-activitypub](https://github.com/pfefferle/wordpress-activitypub).
|
||||||
|
|
||||||
|
### 0.3.1 ###
|
||||||
|
|
||||||
|
* better json encoding
|
||||||
|
|
||||||
### 0.3.0 ###
|
### 0.3.0 ###
|
||||||
|
|
||||||
* basic hashtag support
|
* basic hashtag support
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* Plugin Name: ActivityPub
|
* Plugin Name: ActivityPub
|
||||||
* Plugin URI: https://github.com/pfefferle/wordpress-activitypub/
|
* Plugin URI: https://github.com/pfefferle/wordpress-activitypub/
|
||||||
* Description: The ActivityPub protocol is a decentralized social networking protocol based upon the ActivityStreams 2.0 data format.
|
* Description: The ActivityPub protocol is a decentralized social networking protocol based upon the ActivityStreams 2.0 data format.
|
||||||
* Version: 0.3.0
|
* Version: 0.3.1
|
||||||
* Author: Matthias Pfefferle
|
* Author: Matthias Pfefferle
|
||||||
* Author URI: https://notiz.blog/
|
* Author URI: https://notiz.blog/
|
||||||
* License: MIT
|
* License: MIT
|
||||||
|
|
|
@ -65,7 +65,7 @@ class Activitypub_Activity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function to_json() {
|
public function to_json() {
|
||||||
return wp_json_encode( $this->to_array(), JSON_UNESCAPED_UNICODE );
|
return wp_json_encode( $this->to_array(), JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_QUOT );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function to_simple_array() {
|
public function to_simple_array() {
|
||||||
|
@ -79,6 +79,6 @@ class Activitypub_Activity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function to_simple_json() {
|
public function to_simple_json() {
|
||||||
return wp_json_encode( $this->to_simple_array(), JSON_UNESCAPED_UNICODE );
|
return wp_json_encode( $this->to_simple_array(), JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_QUOT );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ class Activitypub_Post {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function to_json() {
|
public function to_json() {
|
||||||
return wp_json_encode( $this->to_array(), JSON_UNESCAPED_UNICODE );
|
return wp_json_encode( $this->to_array(), JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_QUOT );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_attachments() {
|
public function get_attachments() {
|
||||||
|
@ -262,9 +262,9 @@ class Activitypub_Post {
|
||||||
|
|
||||||
$decoded_content = html_entity_decode( $filtered_content, ENT_QUOTES, 'UTF-8' );
|
$decoded_content = html_entity_decode( $filtered_content, ENT_QUOTES, 'UTF-8' );
|
||||||
|
|
||||||
$allowed_html = apply_filters( 'activitypub_allowed_html', '<a>' );
|
$allowed_html = apply_filters( 'activitypub_allowed_html', '<a><p>' );
|
||||||
|
|
||||||
return trim( preg_replace( '/[\r\n]{2,}/', "\n\n", strip_tags( $decoded_content, $allowed_html) ) );
|
return trim( preg_replace( '/[\r\n]{2,}/', '', strip_tags( $decoded_content, $allowed_html) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -282,9 +282,9 @@ class Activitypub_Post {
|
||||||
|
|
||||||
$decoded_summary = html_entity_decode( $filtered_summary, ENT_QUOTES, 'UTF-8' );
|
$decoded_summary = html_entity_decode( $filtered_summary, ENT_QUOTES, 'UTF-8' );
|
||||||
|
|
||||||
$allowed_html = apply_filters( 'activitypub_allowed_html', '<a>' );
|
$allowed_html = apply_filters( 'activitypub_allowed_html', '<a><p>' );
|
||||||
|
|
||||||
return trim( preg_replace( '/[\r\n]{2,}/', "\n\n", strip_tags( $decoded_summary, $allowed_html) ) );
|
return trim( preg_replace( '/[\r\n]{2,}/', '', strip_tags( $decoded_summary, $allowed_html) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function add_backlink( $content, $post ) {
|
public static function add_backlink( $content, $post ) {
|
||||||
|
@ -296,6 +296,6 @@ class Activitypub_Post {
|
||||||
$link = esc_url( get_permalink( $post->ID ) );
|
$link = esc_url( get_permalink( $post->ID ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $content . "\n\n" . '<a href="' . $link . '">' . $link . '</a>';
|
return $content . '<p><a href="' . $link . '">' . $link . '</a></p>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
# This file is distributed under the MIT.
|
# This file is distributed under the MIT.
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: ActivityPub 0.3.0\n"
|
"Project-Id-Version: ActivityPub 0.3.1\n"
|
||||||
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/activitypub\n"
|
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/activitypub\n"
|
||||||
"POT-Creation-Date: 2019-02-02 22:55:56+00:00\n"
|
"POT-Creation-Date: 2019-02-02 23:38:20+00:00\n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Type: text/plain; charset=utf-8\n"
|
"Content-Type: text/plain; charset=utf-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
|
|
@ -4,7 +4,7 @@ Donate link: https://notiz.blog/donate/
|
||||||
Tags: OStatus, fediverse, activitypub, activitystream
|
Tags: OStatus, fediverse, activitypub, activitystream
|
||||||
Requires at least: 4.7
|
Requires at least: 4.7
|
||||||
Tested up to: 5.1.0
|
Tested up to: 5.1.0
|
||||||
Stable tag: 0.3.0
|
Stable tag: 0.3.1
|
||||||
Requires PHP: 5.6
|
Requires PHP: 5.6
|
||||||
License: MIT
|
License: MIT
|
||||||
License URI: http://opensource.org/licenses/MIT
|
License URI: http://opensource.org/licenses/MIT
|
||||||
|
@ -55,6 +55,10 @@ To implement:
|
||||||
|
|
||||||
Project maintained on github at [pfefferle/wordpress-activitypub](https://github.com/pfefferle/wordpress-activitypub).
|
Project maintained on github at [pfefferle/wordpress-activitypub](https://github.com/pfefferle/wordpress-activitypub).
|
||||||
|
|
||||||
|
= 0.3.1 =
|
||||||
|
|
||||||
|
* better json encoding
|
||||||
|
|
||||||
= 0.3.0 =
|
= 0.3.0 =
|
||||||
|
|
||||||
* basic hashtag support
|
* basic hashtag support
|
||||||
|
|
|
@ -93,7 +93,7 @@ if ( get_query_var( 'pretty' ) ) {
|
||||||
$options |= JSON_PRETTY_PRINT; // phpcs:ignore
|
$options |= JSON_PRETTY_PRINT; // phpcs:ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
$options |= JSON_UNESCAPED_UNICODE;
|
$options |= JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_QUOT;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Options to be passed to json_encode()
|
* Options to be passed to json_encode()
|
||||||
|
|
|
@ -19,7 +19,7 @@ if ( get_query_var( 'pretty' ) ) {
|
||||||
$options |= JSON_PRETTY_PRINT; // phpcs:ignore
|
$options |= JSON_PRETTY_PRINT; // phpcs:ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
$options |= JSON_UNESCAPED_UNICODE;
|
$options |= JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_QUOT;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Options to be passed to json_encode()
|
* Options to be passed to json_encode()
|
||||||
|
|
Loading…
Reference in a new issue