aboutsummaryrefslogtreecommitdiffstats
path: root/include/text.php
diff options
context:
space:
mode:
authorMichael Meer <michael@meer.name>2014-01-30 10:21:21 +0100
committerMichael Meer <michael@meer.name>2014-01-30 10:21:21 +0100
commite5d1e20ff50f49909e7df6fe7efe0d7488e58eaa (patch)
treea3e0b7d7e1f9a4a8a2af39d5c8fad8d62f0411a3 /include/text.php
parentef97a454bbccbd9f7e0e63180c365ed3227fe42c (diff)
parent6c6a9b963a925d33b2cc436d877a4edc5f0d59b1 (diff)
downloadvolse-hubzilla-e5d1e20ff50f49909e7df6fe7efe0d7488e58eaa.tar.gz
volse-hubzilla-e5d1e20ff50f49909e7df6fe7efe0d7488e58eaa.tar.bz2
volse-hubzilla-e5d1e20ff50f49909e7df6fe7efe0d7488e58eaa.zip
Merge branch 'master' of https://github.com/friendica/red
to be in sync with master repro
Diffstat (limited to 'include/text.php')
-rwxr-xr-xinclude/text.php25
1 files changed, 12 insertions, 13 deletions
diff --git a/include/text.php b/include/text.php
index a459296cb..cf68ee121 100755
--- a/include/text.php
+++ b/include/text.php
@@ -871,8 +871,8 @@ function get_mood_verbs() {
* Returns string
*
* It is expected that this function will be called using HTML text.
- * We will escape text between HTML pre and code blocks from being
- * processed.
+ * We will escape text between HTML pre and code blocks, and HTML attributes
+ * (such as urls) from being processed.
*
* At a higher level, the bbcode [nosmile] tag can be used to prevent this
* function from being executed by the prepare_text() routine when preparing
@@ -889,9 +889,8 @@ function smilies($s, $sample = false) {
|| (local_user() && intval(get_pconfig(local_user(),'system','no_smilies'))))
return $s;
- $s = preg_replace_callback('/<pre>(.*?)<\/pre>/ism','smile_encode',$s);
- $s = preg_replace_callback('/<code>(.*?)<\/code>/ism','smile_encode',$s);
-// $s = preg_replace_callback('/<(.*?)>/ism','smile_encode',$s);
+ $s = preg_replace_callback('{<(pre|code)>(?<target>.*?)</\1>}ism','smile_encode',$s);
+ $s = preg_replace_callback('/<[a-z]+ (?<target>.*?)>/ism','smile_encode',$s);
$texts = array(
'&lt;3',
@@ -982,20 +981,20 @@ 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);
-// $s = preg_replace_callback('/<(.*?)>/s','smile_decode',$s);
+ $s = preg_replace_callback(
+ '/<!--base64:(.*?)-->/ism',
+ function ($m) { return base64url_decode($m[1]); },
+ $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]));
+function smile_encode($m) {
+ $cleartext = $m['target'];
+ return str_replace($cleartext,'<!--base64:' . base64url_encode($cleartext) . '-->',$m[0]);
}
// expand <3333 to the correct number of hearts