Skip to content

Commit 34e1eab

Browse files
authored
Merge pull request #570 from bigbitecreative/feature/fix-encoding-issues
Fix encoding issues which affect shortcodes and hashtags
2 parents 6fa2458 + e1052e2 commit 34e1eab

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

classes/class-wpcom-liveblog-entry-extend-feature-hashtags.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,32 @@ public function load() {
3939
// the generated hashtag class.
4040
$this->class_prefix = apply_filters( 'liveblog_hashtag_class', $this->class_prefix );
4141

42+
$prefixes = implode( '|', $this->get_prefixes() );
43+
44+
// Set a better regex for hashtags to allow for hex values in content -- see https://regex101.com/r/CLWsCo/
45+
// phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- ignore indentation
46+
$this->set_regex(
47+
'~'
48+
. '(?:'
49+
. '(?<!\S)' // any visible character
50+
. '|'
51+
. '>?' // possible right angle bracket(s)
52+
. ')'
53+
. '(?:'
54+
. '(?<!'
55+
. '&' // literal ampersand
56+
. '|'
57+
. '&amp;' // encoded ampersand
58+
. ')'
59+
. ')'
60+
. '('
61+
. "(?:{$prefixes})" // hashtag prefixes
62+
. '([0-9_\-\p{L}]*)' // 1: numerals, underscores, dashes, and any letter in any language
63+
. ')'
64+
. '~um'
65+
);
66+
// phpcs:enable
67+
4268
// This is the regex used to revert the
4369
// generated hashtag html back to the
4470
// raw input format (e.g #hashtag).

classes/class-wpcom-liveblog-rest-api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ public static function sanitize_numeric( $param, $request, $key ) {
651651
*/
652652
public static function get_json_param( $param, $json ) {
653653
if ( isset( $json[ $param ] ) ) {
654-
return $json[ $param ];
654+
return html_entity_decode( $json[ $param ] );
655655
}
656656
return false;
657657
}

0 commit comments

Comments
 (0)