diff --git a/tests/src/Content/Text/BBCodeTest.php b/tests/src/Content/Text/BBCodeTest.php
index c7c7220cd9..df4f5c6bfc 100644
--- a/tests/src/Content/Text/BBCodeTest.php
+++ b/tests/src/Content/Text/BBCodeTest.php
@@ -73,51 +73,51 @@ class BBCodeTest extends FixtureTestCase
],
'no-protocol' => [
'data' => 'example.com/path',
- 'assertHTML' => false
+ 'assertHTML' => false,
],
'wrong-protocol' => [
'data' => 'ftp://example.com',
- 'assertHTML' => false
+ 'assertHTML' => false,
],
'wrong-domain-without-path' => [
'data' => 'http://example',
- 'assertHTML' => false
+ 'assertHTML' => false,
],
'wrong-domain-with-path' => [
'data' => 'http://example/path',
- 'assertHTML' => false
+ 'assertHTML' => false,
],
'bug-6857-domain-start' => [
'data' => "http://\nexample.com",
- 'assertHTML' => false
+ 'assertHTML' => false,
],
'bug-6857-domain-end' => [
'data' => "http://example\n.com",
- 'assertHTML' => false
+ 'assertHTML' => false,
],
'bug-6857-tld' => [
'data' => "http://example.\ncom",
- 'assertHTML' => false
+ 'assertHTML' => false,
],
'bug-6857-end' => [
'data' => "http://example.com\ntest",
- 'assertHTML' => false
+ 'assertHTML' => false,
],
'bug-6901' => [
'data' => "http://example.com
",
- 'assertHTML' => false
+ 'assertHTML' => false,
],
'bug-7150' => [
'data' => html_entity_decode('http://example.com ', ENT_QUOTES, 'UTF-8'),
- 'assertHTML' => false
+ 'assertHTML' => false,
],
'bug-7271-query-string-brackets' => [
'data' => 'https://example.com/search?q=square+brackets+[url]',
- 'assertHTML' => true
+ 'assertHTML' => true,
],
'bug-7271-path-brackets' => [
'data' => 'http://example.com/path/to/file[3].html',
- 'assertHTML' => true
+ 'assertHTML' => true,
],
];
}
@@ -215,19 +215,19 @@ class BBCodeTest extends FixtureTestCase
],
'bug-9611-purify-xss-nobb' => [
'expectedHTML' => 'dare to move your mouse here',
- 'text' => '[nobb]dare to move your mouse here[/nobb]'
+ 'text' => '[nobb]dare to move your mouse here[/nobb]',
],
'bug-9611-purify-xss-noparse' => [
'expectedHTML' => 'dare to move your mouse here',
- 'text' => '[noparse]dare to move your mouse here[/noparse]'
+ 'text' => '[noparse]dare to move your mouse here[/noparse]',
],
'bug-9611-purify-xss-attributes' => [
'expectedHTML' => 'dare to move your mouse here',
- 'text' => '[color="onmouseover=alert(0) style="]dare to move your mouse here[/color]'
+ 'text' => '[color="onmouseover=alert(0) style="]dare to move your mouse here[/color]',
],
'bug-9611-purify-attributes-correct' => [
'expectedHTML' => 'dare to move your mouse here',
- 'text' => '[color=FFFFFF]dare to move your mouse here[/color]'
+ 'text' => '[color=FFFFFF]dare to move your mouse here[/color]',
],
'bug-9639-span-classes' => [
'expectedHTML' => 'Test',
@@ -308,11 +308,11 @@ Karl Marx - Die ursprüngliche Akkumulation
],
'bug-12701-quotes' => [
'expected' => '[](https://domain.tld/photos/user/image/86912721086415cdc8e0a03226831581)',
- 'text' => '[url=https://domain.tld/photos/user/image/86912721086415cdc8e0a03226831581][img=https://domain.tld/photo/86912721086415cdc8e0a03226831581-1.png]abc"fgh[/img][/url]'
+ 'text' => '[url=https://domain.tld/photos/user/image/86912721086415cdc8e0a03226831581][img=https://domain.tld/photo/86912721086415cdc8e0a03226831581-1.png]abc"fgh[/img][/url]',
],
'bug-12701-no-quotes' => [
'expected' => '[](https://domain.tld/photos/user/image/86912721086415cdc8e0a03226831581)',
- 'text' => '[url=https://domain.tld/photos/user/image/86912721086415cdc8e0a03226831581][img=https://domain.tld/photo/86912721086415cdc8e0a03226831581-1.png]abcfgh[/img][/url]'
+ 'text' => '[url=https://domain.tld/photos/user/image/86912721086415cdc8e0a03226831581][img=https://domain.tld/photo/86912721086415cdc8e0a03226831581-1.png]abcfgh[/img][/url]',
],
];
}
@@ -345,7 +345,7 @@ Karl Marx - Die ursprüngliche Akkumulation
'bug-10692-start-line' => [
'#[url=https://friendica.local/search?tag=L160]L160[/url]',
'#L160',
- ]
+ ],
];
}
@@ -362,6 +362,58 @@ Karl Marx - Die ursprüngliche Akkumulation
self::assertEquals($expected, $actual);
}
+ public function dataExpandVideoLinks(): array
+ {
+ return [
+ /** @see https://github.com/friendica/friendica/pull/14940 */
+ 'task-14940-youtube-watch-with-www' => [
+ 'expectedBBCode' => '[url=https://www.youtube.com/watch?v=hfwbmTzBFT0]https://www.youtube.com/watch?v=hfwbmTzBFT0[/url]',
+ 'text' => '[youtube]https://www.youtube.com/watch?v=hfwbmTzBFT0[/youtube]',
+ ],
+ 'task-14940-youtube-watch-without-www' => [
+ 'expectedBBCode' => '[url=https://www.youtube.com/watch?v=hfwbmTzBFT0]https://www.youtube.com/watch?v=hfwbmTzBFT0[/url]',
+ 'text' => '[youtube]https://youtube.com/watch?v=hfwbmTzBFT0[/youtube]',
+ ],
+ 'task-14940-youtube-shorts-with-www' => [
+ 'expectedBBCode' => '[url=https://www.youtube.com/watch?v=hfwbmTzBFT0]https://www.youtube.com/watch?v=hfwbmTzBFT0[/url]',
+ 'text' => '[youtube]https://www.youtube.com/shorts/hfwbmTzBFT0[/youtube]',
+ ],
+ 'task-14940-youtube-shorts-without-www' => [
+ 'expectedBBCode' => '[url=https://www.youtube.com/watch?v=hfwbmTzBFT0]https://www.youtube.com/watch?v=hfwbmTzBFT0[/url]',
+ 'text' => '[youtube]https://youtube.com/shorts/hfwbmTzBFT0[/youtube]',
+ ],
+ 'task-14940-youtube-embed-with-www' => [
+ 'expectedBBCode' => '[url=https://www.youtube.com/watch?v=hfwbmTzBFT0]https://www.youtube.com/watch?v=hfwbmTzBFT0[/url]',
+ 'text' => '[youtube]https://www.youtube.com/embed/hfwbmTzBFT0[/youtube]',
+ ],
+ 'task-14940-youtube-embed-without-www' => [
+ 'expectedBBCode' => '[url=https://www.youtube.com/watch?v=hfwbmTzBFT0]https://www.youtube.com/watch?v=hfwbmTzBFT0[/url]',
+ 'text' => '[youtube]https://youtube.com/embed/hfwbmTzBFT0[/youtube]',
+ ],
+ 'task-14940-vimeo' => [
+ 'expectedBBCode' => '[url=https://vimeo.com/2345345]https://vimeo.com/2345345[/url]',
+ 'text' => '[vimeo]https://vimeo.com/2345345[/vimeo]',
+ ],
+ 'task-14940-player-vimeo' => [
+ 'expectedBBCode' => '[url=https://vimeo.com/2345345]https://vimeo.com/2345345[/url]',
+ 'text' => '[vimeo]https://player.vimeo.com/video/2345345[/vimeo]',
+ ],
+ ];
+ }
+
+ /**
+ * @dataProvider dataExpandVideoLinks
+ *
+ * @param string $expected Expected BBCode output
+ * @param string $text Input text
+ */
+ public function testExpandVideoLinks(string $expected, string $text)
+ {
+ $actual = BBCode::expandVideoLinks($text);
+
+ self::assertEquals($expected, $actual);
+ }
+
public function dataGetAbstract(): array
{
return [
diff --git a/tests/src/Content/Text/MarkdownTest.php b/tests/src/Content/Text/MarkdownTest.php
index 6882bec7f1..2174b7670c 100644
--- a/tests/src/Content/Text/MarkdownTest.php
+++ b/tests/src/Content/Text/MarkdownTest.php
@@ -53,6 +53,44 @@ class MarkdownTest extends FixtureTestCase
'expectedBBCode' => 'with the and tag',
'markdown' => 'with the <sup> and </sup> tag',
],
+ /** @see https://github.com/friendica/friendica/pull/14940 */
+ 'task-14940-youtube-watch-with-www' => [
+ 'expectedBBCode' => '[youtube]hfwbmTzBFT0[/youtube]',
+ 'markdown' => '[url=https://www.youtube.com/watch?v=hfwbmTzBFT0]https://www.youtube.com/watch?v=hfwbmTzBFT0[/url]',
+ ],
+ 'task-14940-youtube-watch-without-www' => [
+ 'expectedBBCode' => '[youtube]hfwbmTzBFT0[/youtube]',
+ 'markdown' => '[url=https://youtube.com/watch?v=hfwbmTzBFT0]https://youtube.com/watch?v=hfwbmTzBFT0[/url]',
+ ],
+ 'task-14940-youtube-shorts-with-www' => [
+ 'expectedBBCode' => '[youtube]hfwbmTzBFT0[/youtube]',
+ 'markdown' => '[url=https://www.youtube.com/shorts/hfwbmTzBFT0]https://www.youtube.com/shorts/hfwbmTzBFT0[/url]',
+ ],
+ 'task-14940-youtube-shorts-without-www' => [
+ 'expectedBBCode' => '[youtube]hfwbmTzBFT0[/youtube]',
+ 'markdown' => '[url=https://youtube.com/shorts/hfwbmTzBFT0]https://youtube.com/shorts/hfwbmTzBFT0[/url]',
+ ],
+ 'task-14940-youtube-embed-with-www' => [
+ 'expectedBBCode' => '[youtube]hfwbmTzBFT0[/youtube]',
+ 'markdown' => '[url=https://www.youtube.com/embed/hfwbmTzBFT0]https://www.youtube.com/embed/hfwbmTzBFT0[/url]',
+ ],
+ 'task-14940-youtube-embed-without-www' => [
+ 'expectedBBCode' => '[youtube]hfwbmTzBFT0[/youtube]',
+ 'markdown' => '[url=https://youtube.com/embed/hfwbmTzBFT0]https://youtube.com/embed/hfwbmTzBFT0[/url]',
+ ],
+ // @todo - should we really ignore the URL content in favor of parsing the link of the body?
+ 'task-14940-vimeo-custom-url' => [
+ 'expectedBBCode' => '[vimeo]2345345[/vimeo]',
+ 'markdown' => '[url=https://no.thing]https://vimeo.com/2345345[/url]',
+ ],
+ 'task-14940-vimeo-custom-text' => [
+ 'expectedBBCode' => '[vimeo]2345345[/vimeo]',
+ 'markdown' => '[url=https://vimeo.com/2345345]CustomText[/url]',
+ ],
+ 'task-14940-player-vimeo' => [
+ 'expectedBBCode' => '[vimeo]2345345[/vimeo]',
+ 'markdown' => '[url=https://player.vimeo.com/video/2345345]https://player.vimeo.com/video/2345345[/url]',
+ ],
];
}