From 91c334902565b2ceb7fd26735b4d501973e28557 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 21 Feb 2012 23:13:03 -0800 Subject: escape smiley conversion in code and pre blocks --- include/text.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index 5ef870fd7..38ac58a6c 100755 --- a/include/text.php +++ b/include/text.php @@ -681,6 +681,9 @@ if(! function_exists('smilies')) { function smilies($s, $sample = false) { $a = get_app(); + $s = preg_replace_callback('/
(.*?)<\/pre>/ism','smile_encode',$s);
+	$s = preg_replace_callback('/(.*?)<\/code>/ism','smile_encode',$s);
+
 	$texts =  array( 
 		'<3', 
 		'</3', 
@@ -777,10 +780,24 @@ function smilies($s, $sample = false) {
 		$s = str_replace($params['texts'],$params['icons'],$params['string']);
 	}
 
+	$s = preg_replace_callback('/
(.*?)<\/pre>/ism','smile_decode',$s);
+	$s = preg_replace_callback('/(.*?)<\/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'),
-- 
cgit v1.2.3


From 390eb15e7d00a0616d73cc86595182f099639644 Mon Sep 17 00:00:00 2001
From: friendica 
Date: Wed, 22 Feb 2012 01:50:06 -0800
Subject: never enough documentation

---
 include/text.php | 9 +++++++++
 1 file changed, 9 insertions(+)

(limited to 'include/text.php')

diff --git a/include/text.php b/include/text.php
index 38ac58a6c..0f7d2f731 100755
--- a/include/text.php
+++ b/include/text.php
@@ -675,6 +675,15 @@ 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')) {
-- 
cgit v1.2.3