Merge pull request #10773 from annando/issue-10772
Issue 10772: Avoid duplicated links in AP posts
This commit is contained in:
commit
d9cd2f5bca
|
@ -424,10 +424,12 @@ class BBCode
|
||||||
public static function removeAttachment($body, $no_link_desc = false)
|
public static function removeAttachment($body, $no_link_desc = false)
|
||||||
{
|
{
|
||||||
return preg_replace_callback("/\s*\[attachment (.*?)\](.*?)\[\/attachment\]\s*/ism",
|
return preg_replace_callback("/\s*\[attachment (.*?)\](.*?)\[\/attachment\]\s*/ism",
|
||||||
function ($match) use ($no_link_desc) {
|
function ($match) use ($body, $no_link_desc) {
|
||||||
$attach_data = self::getAttachmentData($match[0]);
|
$attach_data = self::getAttachmentData($match[0]);
|
||||||
if (empty($attach_data['url'])) {
|
if (empty($attach_data['url'])) {
|
||||||
return $match[0];
|
return $match[0];
|
||||||
|
} elseif (strpos(str_replace($match[0], '', $body), $attach_data['url']) !== false) {
|
||||||
|
return '';
|
||||||
} elseif (empty($attach_data['title']) || $no_link_desc) {
|
} elseif (empty($attach_data['title']) || $no_link_desc) {
|
||||||
return " \n[url]" . $attach_data['url'] . "[/url]\n";
|
return " \n[url]" . $attach_data['url'] . "[/url]\n";
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -228,14 +228,14 @@ class BBCodeTest extends MockedTest
|
||||||
'text' => '[size=xx-large]Test text[/size]',
|
'text' => '[size=xx-large]Test text[/size]',
|
||||||
'try_oembed' => false,
|
'try_oembed' => false,
|
||||||
// Triggers the diaspora compatible output
|
// Triggers the diaspora compatible output
|
||||||
'simpleHtml' => 3,
|
'simpleHtml' => BBCode::DIASPORA,
|
||||||
],
|
],
|
||||||
'bug-2199-diaspora-no-numeric-size' => [
|
'bug-2199-diaspora-no-numeric-size' => [
|
||||||
'expectedHtml' => 'Test text',
|
'expectedHtml' => 'Test text',
|
||||||
'text' => '[size=24]Test text[/size]',
|
'text' => '[size=24]Test text[/size]',
|
||||||
'try_oembed' => false,
|
'try_oembed' => false,
|
||||||
// Triggers the diaspora compatible output
|
// Triggers the diaspora compatible output
|
||||||
'simpleHtml' => 3,
|
'simpleHtml' => BBCode::DIASPORA,
|
||||||
],
|
],
|
||||||
'bug-7665-audio-tag' => [
|
'bug-7665-audio-tag' => [
|
||||||
'expectedHtml' => '<audio src="http://www.cendrones.fr/colloque2017/jonathanbocquet.mp3" controls><a href="http://www.cendrones.fr/colloque2017/jonathanbocquet.mp3">http://www.cendrones.fr/colloque2017/jonathanbocquet.mp3</a></audio>',
|
'expectedHtml' => '<audio src="http://www.cendrones.fr/colloque2017/jonathanbocquet.mp3" controls><a href="http://www.cendrones.fr/colloque2017/jonathanbocquet.mp3">http://www.cendrones.fr/colloque2017/jonathanbocquet.mp3</a></audio>',
|
||||||
|
@ -282,6 +282,16 @@ class BBCodeTest extends MockedTest
|
||||||
'expectedHTML' => '<span class="arbitrary classes">Test</span>',
|
'expectedHTML' => '<span class="arbitrary classes">Test</span>',
|
||||||
'text' => '[class=arbitrary classes]Test[/class]',
|
'text' => '[class=arbitrary classes]Test[/class]',
|
||||||
],
|
],
|
||||||
|
'bug-10772-duplicated-links' => [
|
||||||
|
'expectedHTML' => 'Jetzt wird mir klar, warum Kapitalisten jedes Mal durchdrehen wenn Marx und das Kapital ins Gespräch kommt. Soziopathen.<br>Karl Marx - Die ursprüngliche Akkumulation<br><a href="https://wohlstandfueralle.podigee.io/107-urspruengliche-akkumulation" target="_blank" rel="noopener noreferrer">https://wohlstandfueralle.podigee.io/107-urspruengliche-akkumulation</a><br>#Podcast #Kapitalismus',
|
||||||
|
'text' => "Jetzt wird mir klar, warum Kapitalisten jedes Mal durchdrehen wenn Marx und das Kapital ins Gespräch kommt. Soziopathen.
|
||||||
|
Karl Marx - Die ursprüngliche Akkumulation
|
||||||
|
[url=https://wohlstandfueralle.podigee.io/107-urspruengliche-akkumulation]https://wohlstandfueralle.podigee.io/107-urspruengliche-akkumulation[/url]
|
||||||
|
#[url=https://horche.demkontinuum.de/search?tag=Podcast]Podcast[/url] #[url=https://horche.demkontinuum.de/search?tag=Kapitalismus]Kapitalismus[/url]
|
||||||
|
[attachment type='link' url='https://wohlstandfueralle.podigee.io/107-urspruengliche-akkumulation' title='Ep. 107: Karl Marx #8 - Die ursprüngliche Akkumulation' publisher_name='Wohlstand für Alle' preview='https://images.podigee-cdn.net/0x,s6LXshYO7uhG23H431B30t4hxj1bQuzlTsUlze0F_-H8=/https://cdn.podigee.com/uploads/u8126/bd5fe4f4-38b7-4f3f-b269-6a0080144635.jpg']Wie der Kapitalismus funktioniert und inwieweit Menschen darin ausgebeutet werden, haben wir bereits besprochen. Immer wieder verweisen wir auch darauf, dass der Kapitalismus nicht immer schon existierte, sondern historisiert werden muss.[/attachment]",
|
||||||
|
'try_oembed' => false,
|
||||||
|
'simpleHtml' => BBCode::TWITTER,
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user