aboutsummaryrefslogtreecommitdiffstats
path: root/include/text.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/text.php')
-rwxr-xr-xinclude/text.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/include/text.php b/include/text.php
index 5ef870fd7..0f7d2f731 100755
--- a/include/text.php
+++ b/include/text.php
@@ -675,12 +675,24 @@ function linkify($s) {
* @Parameter: string $s
*
* 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.
+ *
+ * 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
+ * bbcode source for HTML display
+ *
*/
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 +789,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'),