From 2f2a316b27221759d433a786fb3485238f032a37 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 26 Aug 2013 03:54:27 -0700 Subject: regex patch --- include/bbcode.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/bbcode.php') diff --git a/include/bbcode.php b/include/bbcode.php index a0a53a310..9f9489893 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -271,7 +271,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $urlchars = '[a-zA-Z0-9\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\+\,]'; if (strpos($Text,'http') !== false) { - $Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/$urlchars+)/ism", '$1$2', $Text); + $Text = preg_replace("/([^\"\]\='".'"'."]|^)(https?\:\/\/$urlchars+)/ism", '$1$2', $Text); } if (strpos($Text,'[/share]') !== false) { $Text = preg_replace_callback("/\[share(.*?)\](.*?)\[\/share\]/ism","bb_ShareAttributes",$Text); -- cgit v1.2.3 From 2e72b136c558652ca9a9b755b29cdb99ee27ee7f Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 26 Aug 2013 17:48:05 -0700 Subject: fix profile change activity where the change is a solitary url - and includes a stray right quote --- include/bbcode.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/bbcode.php') diff --git a/include/bbcode.php b/include/bbcode.php index 9f9489893..a0a53a310 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -271,7 +271,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $urlchars = '[a-zA-Z0-9\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\+\,]'; if (strpos($Text,'http') !== false) { - $Text = preg_replace("/([^\"\]\='".'"'."]|^)(https?\:\/\/$urlchars+)/ism", '$1$2', $Text); + $Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/$urlchars+)/ism", '$1$2', $Text); } if (strpos($Text,'[/share]') !== false) { $Text = preg_replace_callback("/\[share(.*?)\](.*?)\[\/share\]/ism","bb_ShareAttributes",$Text); -- cgit v1.2.3 From c6e527f6fec7f3a5350f8cf794decfd35cea134a Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 27 Aug 2013 05:02:40 -0700 Subject: when using the bbcode mimetype a space is just a space. A return is a return. But as opposed to HTML, two spaces are now non-breaking. A tab (assuming you can figure out how to enter one in a text field) is now four non-breaking spaces. This should let us insert code snippets with much more readable indentation. --- include/bbcode.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include/bbcode.php') diff --git a/include/bbcode.php b/include/bbcode.php index a0a53a310..4647b8567 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -259,6 +259,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $Text = str_replace(array("\n","\r"), array('',''),$Text); + $Text = str_replace(array("\t"," "),array("    ","  "),$Text); // Set up the parameters for a URL search string $URLSearchString = "^\[\]"; -- cgit v1.2.3 From d194ee091af0ee15c7f63def7e8c07ee29e38f39 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 6 Sep 2013 05:25:10 -0700 Subject: encode and decode channel names containing HTML special characters and quotes so they will survive a reshare without mangling --- include/bbcode.php | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) (limited to 'include/bbcode.php') diff --git a/include/bbcode.php b/include/bbcode.php index 4647b8567..997cbac2e 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -106,48 +106,28 @@ function bb_ShareAttributes($match) { $author = ""; preg_match("/author='(.*?)'/ism", $attributes, $matches); if ($matches[1] != "") - $author = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8'); - - preg_match('/author="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $author = $matches[1]; + $author = urldecode($matches[1]); $link = ""; preg_match("/link='(.*?)'/ism", $attributes, $matches); if ($matches[1] != "") $link = $matches[1]; - preg_match('/link="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $link = $matches[1]; - $avatar = ""; preg_match("/avatar='(.*?)'/ism", $attributes, $matches); if ($matches[1] != "") $avatar = $matches[1]; - preg_match('/avatar="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $avatar = $matches[1]; - $profile = ""; preg_match("/profile='(.*?)'/ism", $attributes, $matches); if ($matches[1] != "") $profile = $matches[1]; - preg_match('/profile="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $profile = $matches[1]; - $posted = ""; preg_match("/posted='(.*?)'/ism", $attributes, $matches); if ($matches[1] != "") $posted = $matches[1]; - preg_match('/posted="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $posted = $matches[1]; - // FIXME - this should really be a wall-item-ago so it will get updated on the client $reldate = (($posted) ? relative_date($posted) : ''); -- cgit v1.2.3 From e79bc2924422578a9eb8fc44be59e619a1c158b5 Mon Sep 17 00:00:00 2001 From: zottel Date: Mon, 23 Sep 2013 13:26:23 +0200 Subject: add [observer] tags and [observer.baseurl] --- include/bbcode.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'include/bbcode.php') diff --git a/include/bbcode.php b/include/bbcode.php index 997cbac2e..30bfdad56 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -217,6 +217,18 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $ev = bbtoevent($Text); + // process [observer] tags before we do anything else because we might + // be stripping away stuff that then doesn't need to be worked on anymore + $observer = $a->get_observer(); + if (strpos($Text,'[/observer]') !== false) { + if ($observer) { + $Text = preg_replace("/\[observer(\=1)?\](.*?)\[\/observer\]/ism", '$2', $Text); + $Text = preg_replace("/\[observer\=0\].*?\[\/observer\]/ism", '', $Text); + } else { + $Text = preg_replace("/\[observer(\=1)?\].*?\[\/observer\]/ism", '', $Text); + $Text = preg_replace("/\[observer\=0\](.*?)\[\/observer\]/ism", '$1', $Text); + } + } // Replace any html brackets with HTML Entities to prevent executing HTML or script // Don't use strip_tags here because it breaks [url] search by replacing & with amp @@ -246,6 +258,14 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { // Set up the parameters for a MAIL search string $MAILSearchString = $URLSearchString; + // replace [observer.baseurl] + if ($observer) { + $obsBaseURL = $observer['xchan_url']; + $obsBaseURL = preg_replace("/\/channel\/.*$/", '', $obsBaseURL); + $Text = str_replace('[observer.baseurl]', $obsBaseURL, $Text); + } else { + $Text = str_replace('[observer.baseurl]', '', $Text); + } // Perform URL Search -- cgit v1.2.3 From 1f916adfb889c877ff975be75274fb7f3ac37b1f Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 23 Sep 2013 18:38:08 -0700 Subject: spice this up a little bit... --- include/bbcode.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include/bbcode.php') diff --git a/include/bbcode.php b/include/bbcode.php index 30bfdad56..7d7bf1de4 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -263,8 +263,16 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $obsBaseURL = $observer['xchan_url']; $obsBaseURL = preg_replace("/\/channel\/.*$/", '', $obsBaseURL); $Text = str_replace('[observer.baseurl]', $obsBaseURL, $Text); + $Text = str_replace('[observer.url]',$observer['xchan_url'], $Text); + $Text = str_replace('[observer.name]',$observer['xchan_name'], $Text); + $Text = str_replace('[observer.address]',$observer['xchan_addr'], $Text); + $Text = str_replace('[observer.photo]','[zmg]'.$observer['xchan_photo_l'].'[/zmg]', $Text); } else { $Text = str_replace('[observer.baseurl]', '', $Text); + $Text = str_replace('[observer.url]','', $Text); + $Text = str_replace('[observer.name]','', $Text); + $Text = str_replace('[observer.address]','', $Text); + $Text = str_replace('[observer.photo]','', $Text); } // Perform URL Search -- cgit v1.2.3 From 5092ae9e2bd5edfc67a82c56e803bdcb203386f8 Mon Sep 17 00:00:00 2001 From: zottel Date: Tue, 24 Sep 2013 14:35:47 +0200 Subject: Fix observer=1 tag. Using only observer without =1 won't work anymore now. --- include/bbcode.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/bbcode.php') diff --git a/include/bbcode.php b/include/bbcode.php index 7d7bf1de4..9b9c954c1 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -222,10 +222,10 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $observer = $a->get_observer(); if (strpos($Text,'[/observer]') !== false) { if ($observer) { - $Text = preg_replace("/\[observer(\=1)?\](.*?)\[\/observer\]/ism", '$2', $Text); + $Text = preg_replace("/\[observer\=1\](.*?)\[\/observer\]/ism", '$1', $Text); $Text = preg_replace("/\[observer\=0\].*?\[\/observer\]/ism", '', $Text); } else { - $Text = preg_replace("/\[observer(\=1)?\].*?\[\/observer\]/ism", '', $Text); + $Text = preg_replace("/\[observer\=1\].*?\[\/observer\]/ism", '', $Text); $Text = preg_replace("/\[observer\=0\](.*?)\[\/observer\]/ism", '$1', $Text); } } -- cgit v1.2.3 From b25d2e0d12046786290b95b465643b8cb9bc8c12 Mon Sep 17 00:00:00 2001 From: Thomas Willingham Date: Wed, 2 Oct 2013 05:03:09 +0100 Subject: Slightly modify reshares so they can be themed as a whole. --- include/bbcode.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/bbcode.php') diff --git a/include/bbcode.php b/include/bbcode.php index 9b9c954c1..756d73aba 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -131,7 +131,7 @@ function bb_ShareAttributes($match) { // FIXME - this should really be a wall-item-ago so it will get updated on the client $reldate = (($posted) ? relative_date($posted) : ''); - $headline = '
'; + $headline = '
'; if ($avatar != "") $headline .= '' . $author . ''; @@ -146,7 +146,7 @@ function bb_ShareAttributes($match) { $headline .= '' . $fmt . '
'; - $text = $headline . '
' . trim($match[2]) . '
'; + $text = $headline . '
' . trim($match[2]) . '
'; return($text); } -- cgit v1.2.3