Merge branch 'develop' into rework-addon-class

This commit is contained in:
Art4 2025-06-04 06:27:08 +00:00
commit 1723417f43
30 changed files with 1573 additions and 1220 deletions

View file

@ -13,11 +13,11 @@ use Friendica\Model\Notification;
return [
'gserver' => [
[
'url' => 'https://friendica.local',
'nurl' => 'http://friendica.local',
'register_policy' => 0,
'url' => 'https://friendica.local',
'nurl' => 'http://friendica.local',
'register_policy' => 0,
'registered-users' => 0,
'network' => 'unkn',
'network' => 'unkn',
],
],
// Base test config to avoid notice messages
@ -88,6 +88,11 @@ return [
'uri' => 'https://friendica.local/profile/mutualcontact',
'guid' => '46',
],
[
'id' => 49,
'uri' => 'https://domain.tld/profile/remotecontact',
'guid' => '49',
],
[
'id' => 100,
'uri' => 'https://friendica.local/posts/100',
@ -214,6 +219,23 @@ return [
'network' => Protocol::DFRN,
'location' => 'DFRN',
],
[
'id' => 49,
'uid' => 0,
'uri-id' => 43,
'name' => 'Remote user',
'nick' => 'remotecontact',
'self' => 0,
'nurl' => 'http://domain.tld/profile/remotecontact',
'url' => 'https://domain.tld/profile/remotecontact',
'alias' => 'https://domain.tld/~remotecontact',
'about' => 'User used in tests',
'pending' => 0,
'blocked' => 0,
'rel' => Contact::FOLLOWER,
'network' => Protocol::ACTIVITYPUB,
'location' => 'AP',
],
],
'apcontact' => [
[
@ -343,7 +365,7 @@ return [
'suscipit aut facilis ut inventore omnis exercitationem quo magnam ' .
'consequatur maxime aut illum soluta quaerat natus unde aspernatur ' .
'et sed beatae nihil ullam temporibus corporis ratione blanditiis',
'plink' => 'https://friendica.local/display/6',
'plink' => 'https://friendica.local/display/6',
],
[
'uri-id' => 100,
@ -912,8 +934,8 @@ return [
],
'profile' => [
[
'id' => 1,
'uid' => 42,
'id' => 1,
'uid' => 42,
'locality' => 'DFRN',
],
],
@ -933,18 +955,18 @@ return [
],
'group_member' => [
[
'id' => 1,
'gid' => 1,
'id' => 1,
'gid' => 1,
'contact-id' => 43,
],
[
'id' => 2,
'gid' => 1,
'id' => 2,
'gid' => 1,
'contact-id' => 43,
],
[
'id' => 3,
'gid' => 2,
'id' => 3,
'gid' => 2,
'contact-id' => 43,
],
],

View file

@ -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<ul>",
'assertHTML' => false
'assertHTML' => false,
],
'bug-7150' => [
'data' => html_entity_decode('http://example.com&nbsp;', 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' => '<span>dare to move your mouse here</span>',
'text' => '[nobb]<span onmouseover="alert(0)">dare to move your mouse here</span>[/nobb]'
'text' => '[nobb]<span onmouseover="alert(0)">dare to move your mouse here</span>[/nobb]',
],
'bug-9611-purify-xss-noparse' => [
'expectedHTML' => '<span>dare to move your mouse here</span>',
'text' => '[noparse]<span onmouseover="alert(0)">dare to move your mouse here</span>[/noparse]'
'text' => '[noparse]<span onmouseover="alert(0)">dare to move your mouse here</span>[/noparse]',
],
'bug-9611-purify-xss-attributes' => [
'expectedHTML' => '<span>dare to move your mouse here</span>',
'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' => '<span style="color:#FFFFFF;">dare to move your mouse here</span>',
'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' => '<span class="arbitrary classes">Test</span>',
@ -308,11 +308,16 @@ Karl Marx - Die ursprüngliche Akkumulation
],
'bug-12701-quotes' => [
'expected' => '[![abc"fgh](https://domain.tld/photo/86912721086415cdc8e0a03226831581-1.png)](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' => '[![abcfgh](https://domain.tld/photo/86912721086415cdc8e0a03226831581-1.png "abcfgh")](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]',
],
/** @see https://github.com/friendica/friendica/pull/14908 */
'task-14908-strip-tags' => [
'expected' => 'Norddeutscher Bürger !\[Noddeutscher Bürger - Bismark Brötchen (Roger Cziwerny - pixapay)\](/rscamo/……)',
'text' => '[class=postbox-ocean]Norddeutscher Bürger ![Noddeutscher Bürger - Bismark Brötchen (Roger Cziwerny - pixapay)](/rscamo/……)[/class]',
],
];
}
@ -345,7 +350,7 @@ Karl Marx - Die ursprüngliche Akkumulation
'bug-10692-start-line' => [
'#[url=https://friendica.local/search?tag=L160]L160[/url]',
'#L160',
]
],
];
}
@ -362,6 +367,62 @@ 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-youtube-mobile' => [
'expectedBBCode' => '[url=https://www.youtube.com/watch?v=hfwbmTzBFT0]https://www.youtube.com/watch?v=hfwbmTzBFT0[/url]',
'text' => '[youtube]https://m.youtube.com/watch?v=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 [
@ -615,4 +676,27 @@ Lucas: For the right price, yes.[/share]',
self::assertEquals($expected, $actual);
}
public function dataProfileLink(): array
{
return [
'mention' => [
'expected' => 'Test 1: <bdi>@<a href="https://domain.tld/~remotecontact" class="userinfo mention" title="Remote contact">Remote contact</a></bdi>',
'text' => 'Test 1: @[url=https://domain.tld/profile/remotecontact]Remote contact[/url]',
],
];
}
/**
* @dataProvider dataProfileLink
*
* @param string $expected Expected BBCode output
* @param string $text Input text
*/
public function testProfileLink(string $expected, string $text)
{
$actual = BBCode::convertForUriId(0, $text);
self::assertEquals($expected, $actual);
}
}

View file

@ -51,7 +51,49 @@ class MarkdownTest extends FixtureTestCase
return [
'bug-8358-double-decode' => [
'expectedBBCode' => 'with the <sup> and </sup> tag',
'markdown' => 'with the &lt;sup&gt; and &lt;/sup&gt; tag',
'markdown' => 'with the &lt;sup&gt; and &lt;/sup&gt; 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]',
],
'task-14940-youtube-mobile' => [
'expectedBBCode' => '[youtube]hfwbmTzBFT0[/youtube]',
'markdown' => '[url=https://m.youtube.com/watch?v=hfwbmTzBFT0]https://m.youtube.com/watch?v=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]',
],
];
}