]> git.mxchange.org Git - friendica.git/commitdiff
escape smiley conversion in code and pre blocks
authorfriendica <info@friendica.com>
Wed, 22 Feb 2012 07:13:03 +0000 (23:13 -0800)
committerfriendica <info@friendica.com>
Wed, 22 Feb 2012 07:13:03 +0000 (23:13 -0800)
include/text.php

index 5ef870fd75225d65da744628f00d84ae97fd5893..38ac58a6c30461dab2ea7038baf5bf45e4a049d7 100755 (executable)
@@ -681,6 +681,9 @@ if(! function_exists('smilies')) {
 function smilies($s, $sample = false) {
        $a = get_app();
 
+       $s = preg_replace_callback('/<pre>(.*?)<\/pre>/ism','smile_encode',$s);
+       $s = preg_replace_callback('/<code>(.*?)<\/code>/ism','smile_encode',$s);
+
        $texts =  array( 
                '&lt;3', 
                '&lt;/3', 
@@ -777,10 +780,24 @@ function smilies($s, $sample = false) {
                $s = str_replace($params['texts'],$params['icons'],$params['string']);
        }
 
+       $s = preg_replace_callback('/<pre>(.*?)<\/pre>/ism','smile_decode',$s);
+       $s = preg_replace_callback('/<code>(.*?)<\/code>/ism','smile_decode',$s);
+
        return $s;
 
 }}
 
+function smile_encode($m) {
+       return(str_replace($m[1],base64url_encode($m[1]),$m[0]));
+}
+
+function smile_decode($m) {
+       return(str_replace($m[1],base64url_decode($m[1]),$m[0]));
+}
+
+
+
+
 if(! function_exists('day_translate')) {
 function day_translate($s) {
        $ret = str_replace(array('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'),