!! wikitext
<div title="[[Main Page]]"></div>
!! html
-<div title="[[Main Page]]"></div>
+<div title="[[Main Page]]"></div>
!! end
!! wikitext
<div title="[http://example.com/ link]"></div>
!! html
-<div title="[http://example.com/ link]"></div>
+<div title="[http://example.com/ link]"></div>
!! end
<p><a href="#Foo_bar">#Foo bar</a>
</p>
!! end
+
+!! test
+T51672: Test for brackets in attributes of elements in external link texts
+!! wikitext
+[http://example.com/ link <span title="title with [brackets]">span</span>]
+[http://example.com/ link <span title="title with [brackets]">span</span>]
+
+!! html/php
+<p><a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with [brackets]">span</span></a>
+<a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with [brackets]">span</span></a>
+</p>
+!! end
+
+!! test
+T72875: Test for brackets in attributes of elements in internal link texts
+!! wikitext
+[[Foo|link <span title="title with [[double brackets]]">span</span>]]
+[[Foo|link <span title="title with [[double brackets]]">span</span>]]
+
+!! html/php
+<p><a href="/wiki/Foo" title="Foo">link <span title="title with [[double brackets]]">span</span></a>
+<a href="/wiki/Foo" title="Foo">link <span title="title with [[double brackets]]">span</span></a>
+</p>
+!! end