Index: trunk/phase3/includes/parser/Parser.php |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | |
70 | 70 | # Constants needed for external link processing |
71 | 71 | # Everything except bracket, space, or control characters |
72 | | - const EXT_LINK_URL_CLASS = '[^][<>"\\x00-\\x20\\x7F]'; |
| 72 | + const EXT_LINK_URL_CLASS = '(?:[^\]\[<>"\\x00-\\x20\\x7F]|(?:\[\]))'; |
73 | 73 | const EXT_IMAGE_REGEX = '/^(http:\/\/|https:\/\/)([^][<>"\\x00-\\x20\\x7F]+) |
74 | 74 | \\/([A-Za-z0-9_.,~%\\-+&;#*?!=()@\\x80-\\xFF]+)\\.((?i)gif|png|jpg|jpeg)$/Sx'; |
75 | 75 | |
— | — | @@ -161,7 +161,7 @@ |
162 | 162 | $this->mConf = $conf; |
163 | 163 | $this->mUrlProtocols = wfUrlProtocols(); |
164 | 164 | $this->mExtLinkBracketedRegex = '/\[(\b(' . wfUrlProtocols() . ')'. |
165 | | - '[^][<>"\\x00-\\x20\\x7F]+) *([^\]\\x00-\\x08\\x0a-\\x1F]*?)\]/S'; |
| 165 | + '(?:[^\]\[<>"\x00-\x20\x7F]|\[\])+) *([^\]\\x00-\\x08\\x0a-\\x1F]*?)\]/S'; |
166 | 166 | if ( isset( $conf['preprocessorClass'] ) ) { |
167 | 167 | $this->mPreprocessorClass = $conf['preprocessorClass']; |
168 | 168 | } elseif ( extension_loaded( 'domxml' ) ) { |
Index: trunk/phase3/tests/parser/parserTests.txt |
— | — | @@ -976,6 +976,33 @@ |
977 | 977 | !! end |
978 | 978 | |
979 | 979 | !! test |
| 980 | +External links: links containing empty bracket pair [] |
| 981 | +!! input |
| 982 | +[http://example.com?parameter[]=foo link] |
| 983 | +!! result |
| 984 | +<p><a rel="nofollow" class="external text" href="http://example.com?parameter%5B%5D=foo">link</a> |
| 985 | +</p> |
| 986 | +!! end |
| 987 | + |
| 988 | +!! test |
| 989 | +External links: links ending in empty bracket pair [] |
| 990 | +!! input |
| 991 | +[http://example.com?parameter[]=foo&option[]] |
| 992 | +!! result |
| 993 | +<p><a rel="nofollow" class="external autonumber" href="http://example.com?parameter%5B%5D=foo&option%5B%5D">[1]</a> |
| 994 | +</p> |
| 995 | +!! end |
| 996 | + |
| 997 | +!! test |
| 998 | +External links: bare links ending in empty bracket pair [] |
| 999 | +!! input |
| 1000 | +http://example.com?parameter[]=foo&option[] |
| 1001 | +!! result |
| 1002 | +<p><a rel="nofollow" class="external free" href="http://example.com?parameter%5B%5D=foo&option%5B%5D">http://example.com?parameter%5B%5D=foo&option%5B%5D</a> |
| 1003 | +</p> |
| 1004 | +!! end |
| 1005 | + |
| 1006 | +!! test |
980 | 1007 | BUG 787: Links with one slash after the url protocol are invalid |
981 | 1008 | !! input |
982 | 1009 | http:/example.com |