mirror of
https://framagit.org/hubzilla/core.git
synced 2026-06-21 00:52:33 -04:00
remove some redundant spaces in bbcode to html conversion and fix tests
This commit is contained in:
@@ -1349,7 +1349,7 @@ function bbcode($text, $options = []) {
|
||||
'/([^\]\=\'";\/]|^|\#\^)(geo:([A-Za-z0-9:.,;_+\-?&=%]+)(?:\(([^)]+)\))?)/ismu',
|
||||
function ($matches) {
|
||||
$before = $matches[1];
|
||||
$geo_uri = urldecode($matches[2]);
|
||||
$geo_uri = $matches[2];
|
||||
$label = ((!empty($matches[4])) ? urldecode($matches[4]) : $geo_uri);
|
||||
return $before . '<a href="' . htmlspecialchars($geo_uri) . '" target="_blank" rel="nofollow noopener">' . htmlspecialchars($label) . '</a>';
|
||||
},
|
||||
@@ -1370,23 +1370,23 @@ function bbcode($text, $options = []) {
|
||||
}
|
||||
|
||||
if (strpos($text,'[/url]') !== false) {
|
||||
$text = preg_replace("/\#\^\[url\]([$URLSearchString]*)\[\/url\]/ism", '<span class="bookmark-identifier">#^</span><a class="bookmark" href="$1" ' . $target . ' rel="nofollow noopener" >$1</a>', $text);
|
||||
$text = preg_replace("/\#\^\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '<span class="bookmark-identifier">#^</span><a class="bookmark" href="$1" ' . $target . ' rel="nofollow noopener" >$2</a>', $text);
|
||||
$text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/ism", '<a href="$1" ' . $target . ' rel="nofollow noopener" >$1</a>', $text);
|
||||
$text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '<a href="$1" ' . $target . ' rel="nofollow noopener" >$2</a>', $text);
|
||||
$text = preg_replace("/\#\^\[url\]([$URLSearchString]*)\[\/url\]/ism", '<span class="bookmark-identifier">#^</span><a class="bookmark" href="$1" ' . $target . ' rel="nofollow noopener">$1</a>', $text);
|
||||
$text = preg_replace("/\#\^\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '<span class="bookmark-identifier">#^</span><a class="bookmark" href="$1" ' . $target . ' rel="nofollow noopener">$2</a>', $text);
|
||||
$text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/ism", '<a href="$1" ' . $target . ' rel="nofollow noopener">$1</a>', $text);
|
||||
$text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '<a href="$1" ' . $target . ' rel="nofollow noopener">$2</a>', $text);
|
||||
}
|
||||
|
||||
if (strpos($text,'[/zrl]') !== false) {
|
||||
$text = preg_replace("/\#\^\[zrl\]([$URLSearchString]*)\[\/zrl\]/ism", '<span class="bookmark-identifier">#^</span><a class="zrl bookmark" href="$1" ' . $target . ' rel="nofollow noopener" >$1</a>', $text);
|
||||
$text = preg_replace("/\#\^\[zrl\=([$URLSearchString]*)\](.*?)\[\/zrl\]/ism", '<span class="bookmark-identifier">#^</span><a class="zrl bookmark" href="$1" ' . $target . ' rel="nofollow noopener" >$2</a>', $text);
|
||||
$text = preg_replace("/\[zrl\]([$URLSearchString]*)\[\/zrl\]/ism", '<a class="zrl" href="$1" ' . $target . ' rel="nofollow noopener" >$1</a>', $text);
|
||||
$text = preg_replace("/\[zrl\=([$URLSearchString]*)\](.*?)\[\/zrl\]/ism", '<a class="zrl" href="$1" ' . $target . ' rel="nofollow noopener" >$2</a>', $text);
|
||||
$text = preg_replace("/\#\^\[zrl\]([$URLSearchString]*)\[\/zrl\]/ism", '<span class="bookmark-identifier">#^</span><a class="zrl bookmark" href="$1" ' . $target . ' rel="nofollow noopener">$1</a>', $text);
|
||||
$text = preg_replace("/\#\^\[zrl\=([$URLSearchString]*)\](.*?)\[\/zrl\]/ism", '<span class="bookmark-identifier">#^</span><a class="zrl bookmark" href="$1" ' . $target . ' rel="nofollow noopener">$2</a>', $text);
|
||||
$text = preg_replace("/\[zrl\]([$URLSearchString]*)\[\/zrl\]/ism", '<a class="zrl" href="$1" ' . $target . ' rel="nofollow noopener">$1</a>', $text);
|
||||
$text = preg_replace("/\[zrl\=([$URLSearchString]*)\](.*?)\[\/zrl\]/ism", '<a class="zrl" href="$1" ' . $target . ' rel="nofollow noopener">$2</a>', $text);
|
||||
}
|
||||
|
||||
// Perform MAIL Search
|
||||
if (strpos($text,'[/mail]') !== false) {
|
||||
$text = preg_replace("/\[mail\]([$MAILSearchString]*)\[\/mail\]/", '<a href="mailto:$1" ' . $target . ' rel="nofollow noopener" >$1</a>', $text);
|
||||
$text = preg_replace("/\[mail\=([$MAILSearchString]*)\](.*?)\[\/mail\]/", '<a href="mailto:$1" ' . $target . ' rel="nofollow noopener" >$2</a>', $text);
|
||||
$text = preg_replace("/\[mail\]([$MAILSearchString]*)\[\/mail\]/", '<a href="mailto:$1" ' . $target . ' rel="nofollow noopener">$1</a>', $text);
|
||||
$text = preg_replace("/\[mail\=([$MAILSearchString]*)\](.*?)\[\/mail\]/", '<a href="mailto:$1" ' . $target . ' rel="nofollow noopener">$2</a>', $text);
|
||||
}
|
||||
|
||||
|
||||
@@ -1747,17 +1747,17 @@ function bbcode($text, $options = []) {
|
||||
|
||||
// if video couldn't be embedded, link to it instead.
|
||||
if (strpos($text,'[/video]') !== false) {
|
||||
$text = preg_replace("/\[video\](.*?)\[\/video\]/", '<a href="$1" ' . $target . ' rel="nofollow noopener" >$1</a>', $text);
|
||||
$text = preg_replace("/\[video\](.*?)\[\/video\]/", '<a href="$1" ' . $target . ' rel="nofollow noopener">$1</a>', $text);
|
||||
}
|
||||
if (strpos($text,'[/audio]') !== false) {
|
||||
$text = preg_replace("/\[audio\](.*?)\[\/audio\]/", '<a href="$1" ' . $target . ' rel="nofollow noopener" >$1</a>', $text);
|
||||
$text = preg_replace("/\[audio\](.*?)\[\/audio\]/", '<a href="$1" ' . $target . ' rel="nofollow noopener">$1</a>', $text);
|
||||
}
|
||||
|
||||
if (strpos($text,'[/zvideo]') !== false) {
|
||||
$text = preg_replace("/\[zvideo\](.*?)\[\/zvideo\]/", '<a class="zid" href="$1" ' . $target . ' rel="nofollow noopener" >$1</a>', $text);
|
||||
$text = preg_replace("/\[zvideo\](.*?)\[\/zvideo\]/", '<a class="zid" href="$1" ' . $target . ' rel="nofollow noopener">$1</a>', $text);
|
||||
}
|
||||
if (strpos($text,'[/zaudio]') !== false) {
|
||||
$text = preg_replace("/\[zaudio\](.*?)\[\/zaudio\]/", '<a class="zid" href="$1" ' . $target . ' rel="nofollow noopener" >$1</a>', $text);
|
||||
$text = preg_replace("/\[zaudio\](.*?)\[\/zaudio\]/", '<a class="zid" href="$1" ' . $target . ' rel="nofollow noopener">$1</a>', $text);
|
||||
}
|
||||
|
||||
// oembed tag
|
||||
|
||||
@@ -142,15 +142,15 @@ class BBCodeTest extends UnitTestCase {
|
||||
],
|
||||
'naked url is converted to link' => [
|
||||
'example url: https://example.com',
|
||||
'example url: <a href="https://example.com" target="_blank" rel="nofollow noopener">https://example.com</a>'
|
||||
'example url: <a href="https://example.com" target="_blank" rel="nofollow noopener">https://example.com</a>'
|
||||
],
|
||||
'naked url followed by newline' => [
|
||||
"https://www.example.com\nhave a great day.",
|
||||
'<a href="https://www.example.com" target="_blank" rel="nofollow noopener">https://www.example.com</a><br />have a great day.',
|
||||
'<a href="https://www.example.com" target="_blank" rel="nofollow noopener">https://www.example.com</a><br />have a great day.',
|
||||
],
|
||||
'inline naked url' => [
|
||||
"This is a link https://example.com/some/path more info.",
|
||||
'This is a link <a href="https://example.com/some/path" target="_blank" rel="nofollow noopener">https://example.com/some/path</a> more info.',
|
||||
'This is a link <a href="https://example.com/some/path" target="_blank" rel="nofollow noopener">https://example.com/some/path</a> more info.',
|
||||
],
|
||||
'naked url within code block is not converted to link' => [
|
||||
"[code]\nhttp://example.com\n[/code]",
|
||||
@@ -222,7 +222,7 @@ class BBCodeTest extends UnitTestCase {
|
||||
'[rpost=a title]This is the body[/rpost]',
|
||||
true,
|
||||
'en',
|
||||
'<a href="https://example.com:666/rpost?f=&title=a+title&body=This+is+the+body" target="_blank" rel="nofollow noopener">https://example.com:666/rpost?f=&title=a+title&body=This+is+the+body</a>',
|
||||
'<a href="https://example.com:666/rpost?f=&title=a+title&body=This+is+the+body" target="_blank" rel="nofollow noopener">https://example.com:666/rpost?f=&title=a+title&body=This+is+the+body</a>',
|
||||
],
|
||||
'unauthenticated observer rpost' => [
|
||||
'[rpost=a title]This is the body[/rpost]',
|
||||
|
||||
2
vendor/composer/autoload_classmap.php
vendored
2
vendor/composer/autoload_classmap.php
vendored
@@ -1619,6 +1619,7 @@ return array(
|
||||
'Zotlabs\\Lib\\Img_filesize' => $baseDir . '/Zotlabs/Lib/Img_filesize.php',
|
||||
'Zotlabs\\Lib\\JSalmon' => $baseDir . '/Zotlabs/Lib/JSalmon.php',
|
||||
'Zotlabs\\Lib\\JcsEddsa2022' => $baseDir . '/Zotlabs/Lib/JcsEddsa2022.php',
|
||||
'Zotlabs\\Lib\\JcsEddsa2022SignException' => $baseDir . '/Zotlabs/Lib/JcsEddsa2022SignException.php',
|
||||
'Zotlabs\\Lib\\Keyutils' => $baseDir . '/Zotlabs/Lib/Keyutils.php',
|
||||
'Zotlabs\\Lib\\LDSignatures' => $baseDir . '/Zotlabs/Lib/LDSignatures.php',
|
||||
'Zotlabs\\Lib\\Libsync' => $baseDir . '/Zotlabs/Lib/Libsync.php',
|
||||
@@ -1865,7 +1866,6 @@ return array(
|
||||
'Zotlabs\\Module\\Xchan' => $baseDir . '/Zotlabs/Module/Xchan.php',
|
||||
'Zotlabs\\Module\\Xpoco' => $baseDir . '/Zotlabs/Module/Xpoco.php',
|
||||
'Zotlabs\\Module\\Xrd' => $baseDir . '/Zotlabs/Module/Xrd.php',
|
||||
'Zotlabs\\Module\\Xref' => $baseDir . '/Zotlabs/Module/Xref.php',
|
||||
'Zotlabs\\Module\\Z6trans' => $baseDir . '/Zotlabs/Module/Z6trans.php',
|
||||
'Zotlabs\\Module\\Zot' => $baseDir . '/Zotlabs/Module/Zot.php',
|
||||
'Zotlabs\\Module\\Zot_probe' => $baseDir . '/Zotlabs/Module/Zot_probe.php',
|
||||
|
||||
2
vendor/composer/autoload_static.php
vendored
2
vendor/composer/autoload_static.php
vendored
@@ -1906,6 +1906,7 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
|
||||
'Zotlabs\\Lib\\Img_filesize' => __DIR__ . '/../..' . '/Zotlabs/Lib/Img_filesize.php',
|
||||
'Zotlabs\\Lib\\JSalmon' => __DIR__ . '/../..' . '/Zotlabs/Lib/JSalmon.php',
|
||||
'Zotlabs\\Lib\\JcsEddsa2022' => __DIR__ . '/../..' . '/Zotlabs/Lib/JcsEddsa2022.php',
|
||||
'Zotlabs\\Lib\\JcsEddsa2022SignException' => __DIR__ . '/../..' . '/Zotlabs/Lib/JcsEddsa2022SignException.php',
|
||||
'Zotlabs\\Lib\\Keyutils' => __DIR__ . '/../..' . '/Zotlabs/Lib/Keyutils.php',
|
||||
'Zotlabs\\Lib\\LDSignatures' => __DIR__ . '/../..' . '/Zotlabs/Lib/LDSignatures.php',
|
||||
'Zotlabs\\Lib\\Libsync' => __DIR__ . '/../..' . '/Zotlabs/Lib/Libsync.php',
|
||||
@@ -2152,7 +2153,6 @@ class ComposerStaticInit7b34d7e50a62201ec5d5e526a5b8b35d
|
||||
'Zotlabs\\Module\\Xchan' => __DIR__ . '/../..' . '/Zotlabs/Module/Xchan.php',
|
||||
'Zotlabs\\Module\\Xpoco' => __DIR__ . '/../..' . '/Zotlabs/Module/Xpoco.php',
|
||||
'Zotlabs\\Module\\Xrd' => __DIR__ . '/../..' . '/Zotlabs/Module/Xrd.php',
|
||||
'Zotlabs\\Module\\Xref' => __DIR__ . '/../..' . '/Zotlabs/Module/Xref.php',
|
||||
'Zotlabs\\Module\\Z6trans' => __DIR__ . '/../..' . '/Zotlabs/Module/Z6trans.php',
|
||||
'Zotlabs\\Module\\Zot' => __DIR__ . '/../..' . '/Zotlabs/Module/Zot.php',
|
||||
'Zotlabs\\Module\\Zot_probe' => __DIR__ . '/../..' . '/Zotlabs/Module/Zot_probe.php',
|
||||
|
||||
4
vendor/composer/installed.php
vendored
4
vendor/composer/installed.php
vendored
@@ -3,7 +3,7 @@
|
||||
'name' => 'zotlabs/hubzilla',
|
||||
'pretty_version' => 'dev-10.2RC',
|
||||
'version' => 'dev-10.2RC',
|
||||
'reference' => '457cb748833f0f4926668a18974b6248dac462a7',
|
||||
'reference' => 'd788233bd7c2b99c12bbe0c89f675334baaa29ce',
|
||||
'type' => 'application',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
@@ -430,7 +430,7 @@
|
||||
'zotlabs/hubzilla' => array(
|
||||
'pretty_version' => 'dev-10.2RC',
|
||||
'version' => 'dev-10.2RC',
|
||||
'reference' => '457cb748833f0f4926668a18974b6248dac462a7',
|
||||
'reference' => 'd788233bd7c2b99c12bbe0c89f675334baaa29ce',
|
||||
'type' => 'application',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
|
||||
Reference in New Issue
Block a user