Skip to content

Commit 336f3e5

Browse files
pfefferleedent
andauthored
Fix various encoding issues (#477)
* fix html-entity issue in username * remove kses let other platforms decide what to allow and what not * Remove html_entity_decode to prevent encoding issues (#454) I've tested this on content which includes MarkDown, HTML, encoded entities, unencoded entities, etc. Fixes #445 Co-authored-by: Matthias Pfefferle <[email protected]> * remove allowed tags --------- Co-authored-by: Terence Eden <[email protected]>
1 parent 46b1b47 commit 336f3e5

File tree

2 files changed

+7
-55
lines changed

2 files changed

+7
-55
lines changed

includes/model/class-blog-user.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,13 @@ public function get_type() {
6767
* @return string The User-Name.
6868
*/
6969
public function get_name() {
70-
return \esc_html( \get_bloginfo( 'name' ) );
70+
return \wp_strip_all_tags(
71+
\html_entity_decode(
72+
\get_bloginfo( 'name' ),
73+
\ENT_QUOTES,
74+
'UTF-8'
75+
)
76+
);
7177
}
7278

7379
/**

includes/transformer/class-post.php

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -30,58 +30,6 @@ class Post {
3030
*/
3131
protected $wp_post;
3232

33-
/**
34-
* The Allowed Tags, used in the content.
35-
*
36-
* @var array
37-
*/
38-
protected $allowed_tags = array(
39-
'a' => array(
40-
'href' => array(),
41-
'title' => array(),
42-
'class' => array(),
43-
'rel' => array(),
44-
),
45-
'br' => array(),
46-
'p' => array(
47-
'class' => array(),
48-
),
49-
'span' => array(
50-
'class' => array(),
51-
),
52-
'div' => array(
53-
'class' => array(),
54-
),
55-
'ul' => array(),
56-
'ol' => array(
57-
'reversed' => array(),
58-
'start' => array(),
59-
),
60-
'li' => array(
61-
'value' => array(),
62-
),
63-
'strong' => array(
64-
'class' => array(),
65-
),
66-
'b' => array(
67-
'class' => array(),
68-
),
69-
'i' => array(
70-
'class' => array(),
71-
),
72-
'em' => array(
73-
'class' => array(),
74-
),
75-
'blockquote' => array(),
76-
'cite' => array(),
77-
'code' => array(
78-
'class' => array(),
79-
),
80-
'pre' => array(
81-
'class' => array(),
82-
),
83-
);
84-
8533
/**
8634
* Static function to Transform a WP_Post Object.
8735
*
@@ -513,13 +461,11 @@ protected function get_content() {
513461
$content = do_shortcode( $content );
514462
wp_reset_postdata();
515463

516-
$content = \wp_kses( $content, $this->allowed_tags );
517464
$content = \wpautop( $content );
518465
$content = \preg_replace( '/[\n\r\t]/', '', $content );
519466
$content = \trim( $content );
520467

521468
$content = \apply_filters( 'activitypub_the_content', $content, $post );
522-
$content = \html_entity_decode( $content, \ENT_QUOTES, 'UTF-8' );
523469

524470
return $content;
525471
}

0 commit comments

Comments
 (0)