X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fplugins%2FPluginMarkdownTest.php;h=3593a5563ede8da2525352b09347035528c6d6da;hb=ca089c5bad8ee0f85df571ffa0f0beba51fa4efc;hp=455f5ba7c7d95038b93fdd58af34f76adeea2f52;hpb=893338f0d407a0989454d5e3c0e43c97f7eface5;p=github%2Fshaarli%2FShaarli.git
diff --git a/tests/plugins/PluginMarkdownTest.php b/tests/plugins/PluginMarkdownTest.php
index 455f5ba7..3593a556 100644
--- a/tests/plugins/PluginMarkdownTest.php
+++ b/tests/plugins/PluginMarkdownTest.php
@@ -100,13 +100,55 @@ class PluginMarkdownTest extends PHPUnit_Framework_TestCase
}
/**
- * Test reset_quote_tags()
+ * Test sanitize_html().
*/
- function testResetQuoteTags()
+ function testSanitizeHtml()
{
- $text = '> quote1'. PHP_EOL . ' > quote2 ' . PHP_EOL . 'noquote';
- $processedText = escape($text);
- $reversedText = reset_quote_tags($processedText);
- $this->assertEquals($text, $reversedText);
+ $input = '< script src="js.js"/>';
+ $input .= '< script attr>alert(\'xss\');';
+ $input .= '';
+ $output = escape($input);
+ $input .= 'link';
+ $output .= 'link';
+ $this->assertEquals($output, sanitize_html($input));
+ // Do not touch escaped HTML.
+ $input = escape($input);
+ $this->assertEquals($input, sanitize_html($input));
+ }
+
+ /**
+ * Test the no markdown tag.
+ */
+ function testNoMarkdownTag()
+ {
+ $str = 'All _work_ and `no play` makes Jack a *dull* boy.';
+ $data = array(
+ 'links' => array(array(
+ 'description' => $str,
+ 'tags' => NO_MD_TAG,
+ 'taglist' => array(NO_MD_TAG),
+ ))
+ );
+
+ $data = hook_markdown_render_linklist($data);
+ $this->assertEquals($str, $data['links'][0]['description']);
+
+ $data = array(
+ // Columns data
+ 'cols' => array(
+ // First, second, third.
+ 0 => array(
+ // nth link
+ 0 => array(
+ 'formatedDescription' => $str,
+ 'tags' => NO_MD_TAG,
+ 'taglist' => array(),
+ ),
+ ),
+ ),
+ );
+
+ $data = hook_markdown_render_daily($data);
+ $this->assertEquals($str, $data['cols'][0][0]['formatedDescription']);
}
}