Protect tags from being broken
This commit is contained in:
parent
dbaddd9189
commit
32f5bec23a
1 changed files with 14 additions and 0 deletions
|
@ -43,8 +43,22 @@ class Hashtag {
|
||||||
* @return string the filtered post-content
|
* @return string the filtered post-content
|
||||||
*/
|
*/
|
||||||
public static function the_content( $the_content ) {
|
public static function the_content( $the_content ) {
|
||||||
|
$protected_tags = array();
|
||||||
|
$the_content = preg_replace_callback(
|
||||||
|
'#<[^>]+>#i',
|
||||||
|
function( $m ) use ( &$protected_tags ) {
|
||||||
|
$c = count( $protected_tags );
|
||||||
|
$protect = '!#!#PROTECT' . $c . '#!#!';
|
||||||
|
$protected_tags[ $protect ] = $m[0];
|
||||||
|
return $protect;
|
||||||
|
},
|
||||||
|
$the_content
|
||||||
|
);
|
||||||
|
|
||||||
$the_content = \preg_replace_callback( '/' . ACTIVITYPUB_HASHTAGS_REGEXP . '/i', array( '\Activitypub\Hashtag', 'replace_with_links' ), $the_content );
|
$the_content = \preg_replace_callback( '/' . ACTIVITYPUB_HASHTAGS_REGEXP . '/i', array( '\Activitypub\Hashtag', 'replace_with_links' ), $the_content );
|
||||||
|
|
||||||
|
$the_content = str_replace( array_keys( $protected_tags ), array_values( $protected_tags ), $the_content );
|
||||||
|
|
||||||
return $the_content;
|
return $the_content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue