aboutsummaryrefslogtreecommitdiffstats
path: root/include/diaspora.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-02-07 02:16:28 -0800
committerfriendica <info@friendica.com>2012-02-07 02:16:28 -0800
commita869bd2fe56d1795ab1d8744796a6e908e5adc29 (patch)
treed36f3e029246c038ca8528b88025ec531260ebad /include/diaspora.php
parentc6cdad946eac99ced15cd8fa294ab0fdaa05f3a5 (diff)
downloadvolse-hubzilla-a869bd2fe56d1795ab1d8744796a6e908e5adc29.tar.gz
volse-hubzilla-a869bd2fe56d1795ab1d8744796a6e908e5adc29.tar.bz2
volse-hubzilla-a869bd2fe56d1795ab1d8744796a6e908e5adc29.zip
don't link tags enclosed inside Diaspora links
Diffstat (limited to 'include/diaspora.php')
-rwxr-xr-xinclude/diaspora.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/include/diaspora.php b/include/diaspora.php
index cded389c3..2a4c8b9da 100755
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -673,6 +673,14 @@ function diaspora_post($importer,$xml) {
if(strpos($tag,'#') === 0) {
if(strpos($tag,'[url='))
continue;
+
+ // don't link tags that are already embedded in links
+
+ if(preg_match('/\[(.*?)' . preg_quote($tag) . '(.*?)\]/',$body))
+ continue;
+ if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag) . '(.*?)\)/',$body))
+ continue;
+
$basetag = str_replace('_',' ',substr($tag,1));
$body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
if(strlen($str_tags))
@@ -830,6 +838,15 @@ function diaspora_reshare($importer,$xml) {
if(strpos($tag,'#') === 0) {
if(strpos($tag,'[url='))
continue;
+
+ // don't link tags that are already embedded in links
+
+ if(preg_match('/\[(.*?)' . preg_quote($tag) . '(.*?)\]/',$body))
+ continue;
+ if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag) . '(.*?)\)/',$body))
+ continue;
+
+
$basetag = str_replace('_',' ',substr($tag,1));
$body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
if(strlen($str_tags))
@@ -1062,6 +1079,15 @@ function diaspora_comment($importer,$xml,$msg) {
if(strpos($tag,'#') === 0) {
if(strpos($tag,'[url='))
continue;
+
+ // don't link tags that are already embedded in links
+
+ if(preg_match('/\[(.*?)' . preg_quote($tag) . '(.*?)\]/',$body))
+ continue;
+ if(preg_match('/\[(.*?)\]\((.*?)' . preg_quote($tag) . '(.*?)\)/',$body))
+ continue;
+
+
$basetag = str_replace('_',' ',substr($tag,1));
$body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
if(strlen($str_tags))