Index: trac/wiki/tests/wiki-tests.txt
===================================================================
--- trac/wiki/tests/wiki-tests.txt	(revision 2381)
+++ trac/wiki/tests/wiki-tests.txt	(working copy)
@@ -564,6 +564,38 @@
 <a class="ext-link" href="rfc-2396.compatible://link"><span class="icon"></span>RFC 2396</a>
 </p>
 ==============================
+!Test:[[BR]] There should be a line break
+
+!Change:[10] There should be a link to changeset [10]
+
+Other !test:'''bold text''' is not bold
+------------------------------
+<p>
+Test:<br /> There should be a line break
+</p>
+<p>
+Change:<a class="missing changeset" href="/changeset/10" rel="nofollow">[10]</a> There should be a link to changeset <a class="missing changeset" href="/changeset/10" rel="nofollow">[10]</a>
+</p>
+<p>
+Other test:<strong>bold text</strong> is not bold
+</p>
+==============================
+![Test:[[BR]] There should be a line break]
+
+![Change:[10] There should be a link to changeset [10]]
+
+Other ![test:'''bold text''' is not bold]
+------------------------------
+<p>
+[Test:<br /> There should be a line break]
+</p>
+<p>
+[Change:<a class="missing changeset" href="/changeset/10" rel="nofollow">[10]</a> There should be a link to changeset <a class="missing changeset" href="/changeset/10" rel="nofollow">[10]</a>]
+</p>
+<p>
+Other [test:<strong>bold text</strong> is not bold]
+</p>
+==============================
 = ça marche! =
 ------------------------------
 <h1 id="çamarche">ça marche!</h1>
Index: trac/wiki/formatter.py
===================================================================
--- trac/wiki/formatter.py	(revision 2381)
+++ trac/wiki/formatter.py	(working copy)
@@ -147,10 +147,11 @@
                   r"(?P<inlinecode2>!?%s(?P<inline2>.*?)%s)" % (INLINE_TOKEN,
                                                                 INLINE_TOKEN),
                   r"(?P<htmlescapeentity>!?&#\d+;)"]
-    _post_rules = [(r"(?P<shref>!?((?P<sns>%s):" % LINK_SCHEME +
+    _post_rules = [(r"(?P<escapehref>!\[?%s:)" % LINK_SCHEME),
+                   (r"(?P<shref>(?P<sns>%s):" % LINK_SCHEME +
                     r"(?P<stgt>'[^']+'|\"[^\"]+\"|"
-                    r"(?:\|(?=[^| ])|&(?!lt;)|[^|& ])*[^|'~_\.,& \)])))"),
-                   (r"(?P<lhref>!?\[(?:(?P<lns>%s):" % LINK_SCHEME +
+                    r"(?:\|(?=[^| ])|&(?!lt;)|[^|& ])*[^|'~_\.,& \)]))"),
+                   (r"(?P<lhref>\[(?:(?P<lns>%s):" % LINK_SCHEME +
                     r"(?P<ltgt>'[^']+'|\"[^\"]+\"|[^\] ]*)"
                     r"|(?P<rel>[/.][^ [\]]*))"
                     r"(?: (?P<label>'[^']+'|\"[^\"]+\"|[^\]]+))?\])"),
@@ -247,6 +248,9 @@
             self.open_tag(*italic)
         return tmp
 
+    def _escapehref_formatter(self, match, fullmatch):
+        return match[1:]
+
     def _shref_formatter(self, match, fullmatch):
         ns = fullmatch.group('sns')
         target = fullmatch.group('stgt')

