From f3cd5d03a44db8d87c6f4a5036879637fce5cb8f Mon Sep 17 00:00:00 2001 From: Shish Date: Wed, 30 Dec 2009 09:13:57 +0000 Subject: [PATCH] email bbcode tag --- ext/bbcode/main.php | 2 ++ ext/bbcode/test.php | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/ext/bbcode/main.php b/ext/bbcode/main.php index 1f358c54..c00c7332 100644 --- a/ext/bbcode/main.php +++ b/ext/bbcode/main.php @@ -19,6 +19,7 @@ class BBCode extends FormatterExtension { $text = preg_replace("/>>([^\d].+)/", "
\\1
", $text); $text = preg_replace("/\[url=((?:https?|ftp|irc|mailto):\/\/.*?)\](.*?)\[\/url\]/s", "\\2", $text); $text = preg_replace("/\[url\]((?:https?|ftp|irc|mailto):\/\/.*?)\[\/url\]/s", "\\1", $text); + $text = preg_replace("/\[email\](.*?)\[\/email\]/s", "\\1", $text); $text = preg_replace("/\[img\](https?:\/\/.*?)\[\/img\]/s", "", $text); $text = preg_replace("/\[\[([^\|\]]+)\|([^\]]+)\]\]/s", "\\2", $text); $text = preg_replace("/\[\[([^\]]+)\]\]/s", "\\1", $text); @@ -60,6 +61,7 @@ class BBCode extends FormatterExtension { $text = preg_replace("/\[code\](.*?)\[\/code\]/s", "\\1", $text); $text = preg_replace("/\[url=(.*?)\](.*?)\[\/url\]/s", "\\2", $text); $text = preg_replace("/\[url\](.*?)\[\/url\]/s", "\\1", $text); + $text = preg_replace("/\[email\](.*?)\[\/email\]/s", "\\1", $text); $text = preg_replace("/\[img\](.*?)\[\/img\]/s", "", $text); $text = preg_replace("/\[\[([^\|\]]+)\|([^\]]+)\]\]/s", "\\2", $text); $text = preg_replace("/\[\[([^\]]+)\]\]/s", "\\1", $text); diff --git a/ext/bbcode/test.php b/ext/bbcode/test.php index 6951c5b6..da44d2e0 100644 --- a/ext/bbcode/test.php +++ b/ext/bbcode/test.php @@ -62,6 +62,12 @@ class BBCodeUnitTest extends UnitTestCase { "[url=javascript:alert("owned")]click to fail[/url]"); } + public function testURL() { + $this->assertEqual( + $this->filter("[email]spam@shishnet.org[/email]"), + "spam@shishnet.org"); + } + private function filter($in) { $bb = new BBCode(); $tfe = new TextFormattingEvent($in);