aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2024-10-02 13:10:05 +0000
committerMario <mario@mariovavti.com>2024-10-02 13:10:05 +0000
commit9f49d313f5e9c50873b75d05b48980701361c9c6 (patch)
treed842a43070290eca10b8ba2134ff635a2fd858d6 /tests/unit
parenta5f0253aef7784ace13fa6bd87048b86d9cd50c3 (diff)
parent803cd74b4881a617a56be4fb5780d6d25fd5433f (diff)
downloadvolse-hubzilla-9f49d313f5e9c50873b75d05b48980701361c9c6.tar.gz
volse-hubzilla-9f49d313f5e9c50873b75d05b48980701361c9c6.tar.bz2
volse-hubzilla-9f49d313f5e9c50873b75d05b48980701361c9c6.zip
Merge branch 'markdown/dont-link-urls-in-code-blocks' into 'dev'
markdown: Don't link URLs in code blocks. See merge request hubzilla/core!2145
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/includes/BBCodeTest.php14
-rw-r--r--tests/unit/includes/MarkdownTest.php8
2 files changed, 21 insertions, 1 deletions
diff --git a/tests/unit/includes/BBCodeTest.php b/tests/unit/includes/BBCodeTest.php
index 30ea00ba6..c6a60f35b 100644
--- a/tests/unit/includes/BBCodeTest.php
+++ b/tests/unit/includes/BBCodeTest.php
@@ -138,7 +138,15 @@ class BBCodeTest extends UnitTestCase {
'del tag' => [
'some [s]strike through[/s] text',
'some <del>strike through</del> text'
- ]
+ ],
+ '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>'
+ ],
+ 'naked url within code block is not converted to link' => [
+ "[code]\nhttp://example.com\n[/code]",
+ "<pre><code>http://example.com</code></pre>"
+ ],
];
}
@@ -223,6 +231,10 @@ class BBCodeTest extends UnitTestCase {
"<pre><code>some\n indented\ncode</code></pre>",
"[code]some\n indented\ncode[/code]"
],
+ 'code block with URL' => [
+ '<pre><code>\nproxy_pass http://example.com\n</code></pre>',
+ '[code]\nproxy_pass http://example.com\n[/code]'
+ ],
'paragraph with a mention and some text' => [
'<p><span class="h-card" translate="no"><a href="https://example.org/@profile" class="u-url mention">@<span>profile</span></a></span> some content</p>',
'[url=https://example.org/@profile]@profile[/url] some content'
diff --git a/tests/unit/includes/MarkdownTest.php b/tests/unit/includes/MarkdownTest.php
index 310130bf1..217d12ca2 100644
--- a/tests/unit/includes/MarkdownTest.php
+++ b/tests/unit/includes/MarkdownTest.php
@@ -93,6 +93,14 @@ class MarkdownTest extends UnitTestCase {
"[code=php]&lt;?php\necho phpinfo();[/code]",
"```php\n<?php\necho phpinfo();\n```"
],
+ 'code block with URL' => [
+ "[code]an example url https://example.com[/code]",
+ "```\nan example url https://example.com\n```"
+ ],
+ 'bbcode code block with URL' => [
+ "[code] proxy_pass http://example.com; [/code]",
+ "[code]\nproxy_pass http://example.com;\n[/code]"
+ ]
];
}