3 * @copyright Copyright (C) 2010-2023, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Test\src\Content\Text;
24 use Friendica\Content\Text\BBCode;
26 use Friendica\Network\HTTPException\InternalServerErrorException;
27 use Friendica\Test\FixtureTest;
29 class BBCodeTest extends FixtureTest
31 protected function setUp(): void
34 DI::config()->set('system', 'remove_multiplicated_lines', false);
35 DI::config()->set('system', 'no_oembed', false);
36 DI::config()->set('system', 'allowed_link_protocols', []);
37 DI::config()->set('system', 'url', 'friendica.local');
38 DI::config()->set('system', 'no_smilies', false);
39 DI::config()->set('system', 'big_emojis', false);
40 DI::config()->set('system', 'allowed_oembed', '');
42 DI::baseUrl()->save('friendica.local', DI::baseUrl()::SSL_POLICY_FULL, '');
44 $config = \HTMLPurifier_HTML5Config::createDefault();
45 $config->set('HTML.Doctype', 'HTML5');
46 $config->set('Attr.AllowedRel', [
50 $config->set('Attr.AllowedFrameTargets', [
54 $this->HTMLPurifier = new \HTMLPurifier($config);
57 public function dataLinks()
60 /** @see https://github.com/friendica/friendica/issues/2487 */
62 'data' => 'https://de.wikipedia.org/wiki/Juha_Sipilä',
66 'data' => 'https://de.wikipedia.org/wiki/Dnepr_(Motorradmarke)',
70 'data' => 'https://friendica.wäckerlin.ch/friendica',
74 'data' => 'https://mastodon.social/@morevnaproject',
77 /** @see https://github.com/friendica/friendica/issues/5795 */
79 'data' => 'https://social.nasqueron.org/@liw/100798039015010628',
82 /** @see https://github.com/friendica/friendica/issues/6095 */
84 'data' => 'https://en.wikipedia.org/wiki/Solid_(web_decentralization_project)',
88 'data' => 'example.com/path',
92 'data' => 'ftp://example.com',
95 'wrong-domain-without-path' => [
96 'data' => 'http://example',
99 'wrong-domain-with-path' => [
100 'data' => 'http://example/path',
101 'assertHTML' => false
103 'bug-6857-domain-start' => [
104 'data' => "http://\nexample.com",
105 'assertHTML' => false
107 'bug-6857-domain-end' => [
108 'data' => "http://example\n.com",
109 'assertHTML' => false
112 'data' => "http://example.\ncom",
113 'assertHTML' => false
116 'data' => "http://example.com\ntest",
117 'assertHTML' => false
120 'data' => "http://example.com<ul>",
121 'assertHTML' => false
124 'data' => html_entity_decode('http://example.com ', ENT_QUOTES, 'UTF-8'),
125 'assertHTML' => false
127 'bug-7271-query-string-brackets' => [
128 'data' => 'https://example.com/search?q=square+brackets+[url]',
131 'bug-7271-path-brackets' => [
132 'data' => 'http://example.com/path/to/file[3].html',
139 * Test convert different links inside a text
141 * @dataProvider dataLinks
143 * @param string $data The data to text
144 * @param bool $assertHTML True, if the link is a HTML link (<a href...>...</a>)
146 * @throws InternalServerErrorException
148 public function testAutoLinking(string $data, bool $assertHTML)
150 $output = BBCode::convert($data);
151 $assert = $this->HTMLPurifier->purify('<a href="' . $data . '" target="_blank" rel="noopener noreferrer">' . $data . '</a>');
153 self::assertEquals($assert, $output);
155 self::assertNotEquals($assert, $output);
159 public function dataBBCodes()
162 'bug-7271-condensed-space' => [
163 'expectedHtml' => '<ul class="listdecimal" style="list-style-type:decimal;"><li> <a href="http://example.com/" target="_blank" rel="noopener noreferrer">http://example.com/</a></li></ul>',
164 'text' => '[ol][*] http://example.com/[/ol]',
166 'bug-7271-condensed-nospace' => [
167 'expectedHtml' => '<ul class="listdecimal" style="list-style-type:decimal;"><li><a href="http://example.com/" target="_blank" rel="noopener noreferrer">http://example.com/</a></li></ul>',
168 'text' => '[ol][*]http://example.com/[/ol]',
170 'bug-7271-indented-space' => [
171 'expectedHtml' => '<ul class="listbullet" style="list-style-type:circle;"><li> <a href="http://example.com/" target="_blank" rel="noopener noreferrer">http://example.com/</a></li></ul>',
173 [*] http://example.com/
176 'bug-7271-indented-nospace' => [
177 'expectedHtml' => '<ul class="listbullet" style="list-style-type:circle;"><li><a href="http://example.com/" target="_blank" rel="noopener noreferrer">http://example.com/</a></li></ul>',
179 [*]http://example.com/
182 'bug-2199-named-size' => [
183 'expectedHtml' => '<span style="font-size:xx-large;line-height:normal;">Test text</span>',
184 'text' => '[size=xx-large]Test text[/size]',
186 'bug-2199-numeric-size' => [
187 'expectedHtml' => '<span style="font-size:24px;line-height:normal;">Test text</span>',
188 'text' => '[size=24]Test text[/size]',
190 'bug-2199-diaspora-no-named-size' => [
191 'expectedHtml' => 'Test text',
192 'text' => '[size=xx-large]Test text[/size]',
193 'try_oembed' => false,
194 // Triggers the diaspora compatible output
195 'simpleHtml' => BBCode::DIASPORA,
197 'bug-2199-diaspora-no-numeric-size' => [
198 'expectedHtml' => 'Test text',
199 'text' => '[size=24]Test text[/size]',
200 'try_oembed' => false,
201 // Triggers the diaspora compatible output
202 'simpleHtml' => BBCode::DIASPORA,
204 'bug-7665-audio-tag' => [
205 '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>',
206 'text' => '[audio]http://www.cendrones.fr/colloque2017/jonathanbocquet.mp3[/audio]',
207 'try_oembed' => true,
209 'bug-7808-code-lt' => [
210 'expectedHtml' => '<code><</code>',
211 'text' => '[code]<[/code]',
213 'bug-7808-code-gt' => [
214 'expectedHtml' => '<code>></code>',
215 'text' => '[code]>[/code]',
217 'bug-7808-code-amp' => [
218 'expectedHtml' => '<code>&</code>',
219 'text' => '[code]&[/code]',
221 'task-8800-pre-spaces-notag' => [
222 'expectedHtml' => '[test] Space',
223 'text' => '[test] Space',
225 'task-8800-pre-spaces' => [
226 'expectedHtml' => ' Spaces',
227 'text' => '[pre] Spaces[/pre]',
229 'bug-9611-purify-xss-nobb' => [
230 'expectedHTML' => '<span>dare to move your mouse here</span>',
231 'text' => '[nobb]<span onmouseover="alert(0)">dare to move your mouse here</span>[/nobb]'
233 'bug-9611-purify-xss-noparse' => [
234 'expectedHTML' => '<span>dare to move your mouse here</span>',
235 'text' => '[noparse]<span onmouseover="alert(0)">dare to move your mouse here</span>[/noparse]'
237 'bug-9611-purify-xss-attributes' => [
238 'expectedHTML' => '<span>dare to move your mouse here</span>',
239 'text' => '[color="onmouseover=alert(0) style="]dare to move your mouse here[/color]'
241 'bug-9611-purify-attributes-correct' => [
242 'expectedHTML' => '<span style="color:#FFFFFF;">dare to move your mouse here</span>',
243 'text' => '[color=FFFFFF]dare to move your mouse here[/color]'
245 'bug-9639-span-classes' => [
246 'expectedHTML' => '<span class="arbitrary classes">Test</span>',
247 'text' => '[class=arbitrary classes]Test[/class]',
249 'bug-10772-duplicated-links' => [
250 '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',
251 'text' => "Jetzt wird mir klar, warum Kapitalisten jedes Mal durchdrehen wenn Marx und das Kapital ins Gespräch kommt. Soziopathen.
252 Karl Marx - Die ursprüngliche Akkumulation
253 [url=https://wohlstandfueralle.podigee.io/107-urspruengliche-akkumulation]https://wohlstandfueralle.podigee.io/107-urspruengliche-akkumulation[/url]
254 #[url=https://horche.demkontinuum.de/search?tag=Podcast]Podcast[/url] #[url=https://horche.demkontinuum.de/search?tag=Kapitalismus]Kapitalismus[/url]
255 [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]",
256 'try_oembed' => false,
257 'simpleHtml' => BBCode::TWITTER,
259 'task-10886-deprecate-class' => [
260 'expectedHTML' => '<span class="mastodon emoji"><img src="https://fedi.underscore.world/emoji/custom/custom/heart_nb.png" alt=":heart_nb:" title=":heart_nb:"></span>',
261 'text' => '[emoji=https://fedi.underscore.world/emoji/custom/custom/heart_nb.png]:heart_nb:[/emoji]',
267 * Test convert bbcodes to HTML
269 * @dataProvider dataBBCodes
271 * @param string $expectedHtml Expected HTML output
272 * @param string $text BBCode text
273 * @param bool $try_oembed Whether to convert multimedia BBCode tag
274 * @param int $simpleHtml BBCode::convert method $simple_html parameter value, optional.
275 * @param bool $forPlaintext BBCode::convert method $for_plaintext parameter value, optional.
277 * @throws InternalServerErrorException
279 public function testConvert(string $expectedHtml, string $text, $try_oembed = false, int $simpleHtml = 0, bool $forPlaintext = false)
281 $actual = BBCode::convert($text, $try_oembed, $simpleHtml, $forPlaintext);
283 self::assertEquals($expectedHtml, $actual);
286 public function dataBBCodesToMarkdown()
290 'expected' => '>`>`',
291 'text' => '>[code]>[/code]',
294 'expected' => '<`<`',
295 'text' => '<[code]<[/code]',
298 'expected' => '&`&`',
299 'text' => '&[code]&[/code]',
305 * Test convert bbcodes to Markdown
307 * @dataProvider dataBBCodesToMarkdown
309 * @param string $expected Expected Markdown output
310 * @param string $text BBCode text
311 * @param bool $for_diaspora
313 * @throws InternalServerErrorException
315 public function testToMarkdown(string $expected, string $text, $for_diaspora = false)
317 $actual = BBCode::toMarkdown($text, $for_diaspora);
319 self::assertEquals($expected, $actual);
322 public function dataExpandTags()
325 'bug-10692-non-word' => [
326 '[url=https://github.com/friendica/friendica/blob/2021.09-rc/src/Util/Logger/StreamLogger.php#L160]https://github.com/friendica/friendica/blob/2021.09-rc/src/Util/Logger/StreamLogger.php#L160[/url]',
327 '[url=https://github.com/friendica/friendica/blob/2021.09-rc/src/Util/Logger/StreamLogger.php#L160]https://github.com/friendica/friendica/blob/2021.09-rc/src/Util/Logger/StreamLogger.php#L160[/url]',
329 'bug-10692-start-line' => [
330 '#[url=https://friendica.local/search?tag=L160]L160[/url]',
337 * @dataProvider dataExpandTags
339 * @param string $expected Expected BBCode output
340 * @param string $text Input text
342 public function testExpandTags(string $expected, string $text)
344 $actual = BBCode::expandTags($text);
346 self::assertEquals($expected, $actual);
349 public function dataGetAbstract(): array
354 'text' => 'Venture the only home we\'ve ever known laws of physics tendrils of gossamer clouds a still more glorious dawn awaits Sea of Tranquility. With pretty stories for which there\'s little good evidence the ash of stellar alchemy corpus callosum preserve and cherish that pale blue dot descended from astronomers preserve and cherish that pale blue dot. A mote of dust suspended in a sunbeam paroxysm of global death two ghostly white figures in coveralls and helmets are softly dancing descended from astronomers star stuff harvesting star light gathered by gravity and billions upon billions upon billions upon billions upon billions upon billions upon billions.',
357 'no-abstract-addon' => [
359 'text' => 'Tingling of the spine tendrils of gossamer clouds Flatland trillion rich in heavy atoms of brilliant syntheses. Extraordinary claims require extraordinary evidence a very small stage in a vast cosmic arena made in the interiors of collapsing stars kindling the energy hidden in matter vastness is bearable only through love kindling the energy hidden in matter? Dispassionate extraterrestrial observer preserve and cherish that pale blue dot vastness is bearable only through love emerged into consciousness encyclopaedia galactica a still more glorious dawn awaits and billions upon billions upon billions upon billions upon billions upon billions upon billions.',
363 'expected' => 'Abstract at the beginning of the text',
364 'text' => '[abstract]Abstract at the beginning of the text[/abstract]A very small stage in a vast cosmic arena the ash of stellar alchemy rich in heavy atoms a still more glorious dawn awaits are creatures of the cosmos Orion\'s sword. Brain is the seed of intelligence dream of the mind\'s eye inconspicuous motes of rock and gas extraordinary claims require extraordinary evidence vastness is bearable only through love quasar? Made in the interiors of collapsing stars the carbon in our apple pies cosmic ocean citizens of distant epochs paroxysm of global death dispassionate extraterrestrial observer and billions upon billions upon billions upon billions upon billions upon billions upon billions.',
367 'abstract-addon-not-present' => [
368 'expected' => 'Abstract at the beginning of the text',
369 'text' => '[abstract]Abstract at the beginning of the text[/abstract]With pretty stories for which there\'s little good evidence rogue not a sunrise but a galaxyrise tingling of the spine birth cosmic fugue. Cosmos hundreds of thousands Apollonius of Perga network of wormholes rich in mystery globular star cluster. Another world vastness is bearable only through love encyclopaedia galactica something incredible is waiting to be known invent the universe hearts of the stars. Extraordinary claims require extraordinary evidence the sky calls to us the only home we\'ve ever known the sky calls to us the sky calls to us extraordinary claims require extraordinary evidence and billions upon billions upon billions upon billions upon billions upon billions upon billions.',
372 'abstract-addon-present' => [
373 'expected' => 'Abstract DFRN in the middle of the text',
374 'text' => '[abstract]Abstract at the beginning of the text[/abstract][abstract=dfrn]Abstract DFRN in the middle of the text[/abstract]Kindling the energy hidden in matter hydrogen atoms at the edge of forever vanquish the impossible ship of the imagination take root and flourish. Tingling of the spine white dwarf as a patch of light the sky calls to us Drake Equation citizens of distant epochs. Concept of the number one dispassionate extraterrestrial observer citizens of distant epochs descended from astronomers extraordinary claims require extraordinary evidence something incredible is waiting to be known and billions upon billions upon billions upon billions upon billions upon billions upon billions.',
377 'abstract-multiple-addon-present' => [
378 'expected' => 'Abstract DFRN at the end of the text',
379 'text' => '[abstract]Abstract at the beginning of the text[/abstract][abstract=ap]Abstract AP in the middle of the text[/abstract]Cambrian explosion rich in heavy atoms take root and flourish radio telescope light years cosmic fugue. Dispassionate extraterrestrial observer white dwarf the sky calls to us another world courage of our questions two ghostly white figures in coveralls and helmets are softly dancing. Extraordinary claims require extraordinary evidence concept of the number one not a sunrise but a galaxyrise are creatures of the cosmos two ghostly white figures in coveralls and helmets are softly dancing white dwarf and billions upon billions upon billions upon billions upon billions upon billions upon billions.[abstract=dfrn]Abstract DFRN at the end of the text[/abstract]',
382 'bug-11445-code-abstract' => [
384 'text' => '[code][abstract]This should not be converted[/abstract][/code]',
387 'bug-11445-noparse-abstract' => [
389 'text' => '[noparse][abstract]This should not be converted[/abstract][/noparse]',
392 'bug-11445-nobb-abstract' => [
394 'text' => '[nobb][abstract]This should not be converted[/abstract][/nobb]',
397 'bug-11445-pre-abstract' => [
399 'text' => '[pre][abstract]This should not be converted[/abstract][/pre]',
406 * @dataProvider dataGetAbstract
408 * @param string $expected Expected abstract text
409 * @param string $text Input text
410 * @param string $addon Optional addon we're searching the abstract for
412 public function testGetAbstract(string $expected, string $text, string $addon)
414 $actual = BBCode::getAbstract($text, $addon);
416 self::assertEquals($expected, $actual);
420 public function dataStripAbstract(): array
424 'expected' => 'Venture the only home we\'ve ever known laws of physics tendrils of gossamer clouds a still more glorious dawn awaits Sea of Tranquility. With pretty stories for which there\'s little good evidence the ash of stellar alchemy corpus callosum preserve and cherish that pale blue dot descended from astronomers preserve and cherish that pale blue dot. A mote of dust suspended in a sunbeam paroxysm of global death two ghostly white figures in coveralls and helmets are softly dancing descended from astronomers star stuff harvesting star light gathered by gravity and billions upon billions upon billions upon billions upon billions upon billions upon billions.',
425 'text' => 'Venture the only home we\'ve ever known laws of physics tendrils of gossamer clouds a still more glorious dawn awaits Sea of Tranquility. With pretty stories for which there\'s little good evidence the ash of stellar alchemy corpus callosum preserve and cherish that pale blue dot descended from astronomers preserve and cherish that pale blue dot. A mote of dust suspended in a sunbeam paroxysm of global death two ghostly white figures in coveralls and helmets are softly dancing descended from astronomers star stuff harvesting star light gathered by gravity and billions upon billions upon billions upon billions upon billions upon billions upon billions.',
428 'expected' => ' A very small stage in a vast cosmic arena the ash of stellar alchemy rich in heavy atoms a still more glorious dawn awaits are creatures of the cosmos Orion\'s sword. Brain is the seed of intelligence dream of the mind\'s eye inconspicuous motes of rock and gas extraordinary claims require extraordinary evidence vastness is bearable only through love quasar? Made in the interiors of collapsing stars the carbon in our apple pies cosmic ocean citizens of distant epochs paroxysm of global death dispassionate extraterrestrial observer and billions upon billions upon billions upon billions upon billions upon billions upon billions.',
429 'text' => '[abstract]Abstract at the beginning of the text[/abstract]A very small stage in a vast cosmic arena the ash of stellar alchemy rich in heavy atoms a still more glorious dawn awaits are creatures of the cosmos Orion\'s sword. Brain is the seed of intelligence dream of the mind\'s eye inconspicuous motes of rock and gas extraordinary claims require extraordinary evidence vastness is bearable only through love quasar? Made in the interiors of collapsing stars the carbon in our apple pies cosmic ocean citizens of distant epochs paroxysm of global death dispassionate extraterrestrial observer and billions upon billions upon billions upon billions upon billions upon billions upon billions.',
431 'abstract-addon' => [
432 'expected' => ' Kindling the energy hidden in matter hydrogen atoms at the edge of forever vanquish the impossible ship of the imagination take root and flourish. Tingling of the spine white dwarf as a patch of light the sky calls to us Drake Equation citizens of distant epochs. Concept of the number one dispassionate extraterrestrial observer citizens of distant epochs descended from astronomers extraordinary claims require extraordinary evidence something incredible is waiting to be known and billions upon billions upon billions upon billions upon billions upon billions upon billions.',
433 'text' => '[abstract]Abstract at the beginning of the text[/abstract][abstract=dfrn]Abstract DFRN in the middle of the text[/abstract]Kindling the energy hidden in matter hydrogen atoms at the edge of forever vanquish the impossible ship of the imagination take root and flourish. Tingling of the spine white dwarf as a patch of light the sky calls to us Drake Equation citizens of distant epochs. Concept of the number one dispassionate extraterrestrial observer citizens of distant epochs descended from astronomers extraordinary claims require extraordinary evidence something incredible is waiting to be known and billions upon billions upon billions upon billions upon billions upon billions upon billions.',
435 'abstract-multiple-addon-present' => [
436 'expected' => ' Cambrian explosion rich in heavy atoms take root and flourish radio telescope light years cosmic fugue. Dispassionate extraterrestrial observer white dwarf the sky calls to us another world courage of our questions two ghostly white figures in coveralls and helmets are softly dancing. Extraordinary claims require extraordinary evidence concept of the number one not a sunrise but a galaxyrise are creatures of the cosmos two ghostly white figures in coveralls and helmets are softly dancing white dwarf and billions upon billions upon billions upon billions upon billions upon billions upon billions. ',
437 'text' => '[abstract]Abstract at the beginning of the text[/abstract][abstract=ap]Abstract AP in the middle of the text[/abstract]Cambrian explosion rich in heavy atoms take root and flourish radio telescope light years cosmic fugue. Dispassionate extraterrestrial observer white dwarf the sky calls to us another world courage of our questions two ghostly white figures in coveralls and helmets are softly dancing. Extraordinary claims require extraordinary evidence concept of the number one not a sunrise but a galaxyrise are creatures of the cosmos two ghostly white figures in coveralls and helmets are softly dancing white dwarf and billions upon billions upon billions upon billions upon billions upon billions upon billions.[abstract=dfrn]Abstract DFRN at the end of the text[/abstract]',
439 'bug-11445-code-abstract' => [
440 'expected' => '[code][abstract]This should not be converted[/abstract][/code]',
441 'text' => '[code][abstract]This should not be converted[/abstract][/code]',
443 'bug-11445-noparse-abstract' => [
444 'expected' => '[noparse][abstract]This should not be converted[/abstract][/noparse]',
445 'text' => '[noparse][abstract]This should not be converted[/abstract][/noparse]',
447 'bug-11445-nobb-abstract' => [
448 'expected' => '[nobb][abstract]This should not be converted[/abstract][/nobb]',
449 'text' => '[nobb][abstract]This should not be converted[/abstract][/nobb]',
451 'bug-11445-pre-abstract' => [
452 'expected' => '[pre][abstract]This should not be converted[/abstract][/pre]',
453 'text' => '[pre][abstract]This should not be converted[/abstract][/pre]',
459 * @dataProvider dataStripAbstract
461 * @param string $expected Expected text without abstracts
462 * @param string $text Input text
464 public function testStripAbstract(string $expected, string $text)
466 $actual = BBCode::stripAbstract($text);
468 self::assertEquals($expected, $actual);
471 public function dataFetchShareAttributes(): array
476 'text' => 'Venture the only home we\'ve ever known laws of physics tendrils of gossamer clouds a still more glorious dawn awaits Sea of Tranquility. With pretty stories for which there\'s little good evidence the ash of stellar alchemy corpus callosum preserve and cherish that pale blue dot descended from astronomers preserve and cherish that pale blue dot. A mote of dust suspended in a sunbeam paroxysm of global death two ghostly white figures in coveralls and helmets are softly dancing descended from astronomers star stuff harvesting star light gathered by gravity and billions upon billions upon billions upon billions upon billions upon billions upon billions.',
494 'text' => '[share][/share]',
496 'comment-shared' => [
504 'message_id' => 'https://friendica.mrpetovan.com/display/735a2029-1062-ab23-42e4-f9c631220243',
505 'comment' => 'comment',
509 [share]https://friendica.mrpetovan.com/display/735a2029-1062-ab23-42e4-f9c631220243[/share]',
511 'all-attributes' => [
513 'author' => 'Hypolite Petovan',
514 'profile' => 'https://friendica.mrpetovan.com/profile/hypolite',
515 'avatar' => 'https://friendica.mrpetovan.com/photo/20682437145daa4e85f019a278584494-5.png',
516 'link' => 'https://friendica.mrpetovan.com/display/735a2029-1062-ab23-42e4-f9c631220243',
517 'posted' => '2022-06-16 12:34:10',
518 'guid' => '735a2029-1062-ab23-42e4-f9c631220243',
519 'message_id' => 'https://friendica.mrpetovan.com/display/735a2029-1062-ab23-42e4-f9c631220243',
521 'shared' => 'George Lucas: I made a science-fiction universe with a straightforward anti-authoritarianism plot where even the libertarian joins the rebellion.
522 Disney: So a morally grey “choose your side” story, right?
523 Lucas: For the right price, yes.',
526 author='Hypolite Petovan'
527 profile='https://friendica.mrpetovan.com/profile/hypolite'
528 avatar='https://friendica.mrpetovan.com/photo/20682437145daa4e85f019a278584494-5.png'
529 link='https://friendica.mrpetovan.com/display/735a2029-1062-ab23-42e4-f9c631220243'
530 posted='2022-06-16 12:34:10'
531 guid='735a2029-1062-ab23-42e4-f9c631220243'
532 message_id='https://friendica.mrpetovan.com/display/735a2029-1062-ab23-42e4-f9c631220243'
533 ]George Lucas: I made a science-fiction universe with a straightforward anti-authoritarianism plot where even the libertarian joins the rebellion.
534 Disney: So a morally grey “choose your side” story, right?
535 Lucas: For the right price, yes.[/share]",
537 'optional-attributes' => [
539 'author' => 'Hypolite Petovan',
540 'profile' => 'https://friendica.mrpetovan.com/profile/hypolite',
541 'avatar' => 'https://friendica.mrpetovan.com/photo/20682437145daa4e85f019a278584494-5.png',
542 'link' => 'https://friendica.mrpetovan.com/display/735a2029-1062-ab23-42e4-f9c631220243',
543 'posted' => '2022-06-16 12:34:10',
545 'message_id' => 'https://friendica.mrpetovan.com/display/735a2029-1062-ab23-42e4-f9c631220243',
547 'shared' => 'George Lucas: I made a science-fiction universe with a straightforward anti-authoritarianism plot where even the libertarian joins the rebellion.
548 Disney: So a morally grey “choose your side” story, right?
549 Lucas: For the right price, yes.',
552 author='Hypolite Petovan'
553 profile='https://friendica.mrpetovan.com/profile/hypolite'
554 avatar='https://friendica.mrpetovan.com/photo/20682437145daa4e85f019a278584494-5.png'
555 link='https://friendica.mrpetovan.com/display/735a2029-1062-ab23-42e4-f9c631220243'
556 posted='2022-06-16 12:34:10'
557 message_id='https://friendica.mrpetovan.com/display/735a2029-1062-ab23-42e4-f9c631220243'
558 ]George Lucas: I made a science-fiction universe with a straightforward anti-authoritarianism plot where even the libertarian joins the rebellion.
559 Disney: So a morally grey “choose your side” story, right?
560 Lucas: For the right price, yes.[/share]",
564 'author' => 'Hypolite Petovan',
565 'profile' => 'https://friendica.mrpetovan.com/profile/hypolite',
566 'avatar' => 'https://friendica.mrpetovan.com/photo/20682437145daa4e85f019a278584494-5.png',
567 'link' => 'https://friendica.mrpetovan.com/display/735a2029-1062-ab23-42e4-f9c631220243',
568 'posted' => '2022-06-16 12:34:10',
570 'message_id' => 'https://friendica.mrpetovan.com/display/735a2029-1062-ab23-42e4-f9c631220243',
572 'shared' => 'George Lucas: I made a science-fiction universe with a straightforward anti-authoritarianism plot where even the libertarian joins the rebellion.
573 Disney: So a morally grey “choose your side” story, right?
574 Lucas: For the right price, yes.',
577 author="Hypolite Petovan"
578 profile="https://friendica.mrpetovan.com/profile/hypolite"
579 avatar="https://friendica.mrpetovan.com/photo/20682437145daa4e85f019a278584494-5.png"
580 link="https://friendica.mrpetovan.com/display/735a2029-1062-ab23-42e4-f9c631220243"
581 message_id="https://friendica.mrpetovan.com/display/735a2029-1062-ab23-42e4-f9c631220243"
582 posted="2022-06-16 12:34:10"
583 ]George Lucas: I made a science-fiction universe with a straightforward anti-authoritarianism plot where even the libertarian joins the rebellion.
584 Disney: So a morally grey “choose your side” story, right?
585 Lucas: For the right price, yes.[/share]',
591 * @dataProvider dataFetchShareAttributes
593 * @param array $expected Expected attribute array
594 * @param string $text Input text
596 public function testFetchShareAttributes(array $expected, string $text)
598 $actual = BBCode::fetchShareAttributes($text);
600 self::assertEquals($expected, $actual);