Index: trunk/extensions/UsernameBlacklist/README |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | USERNAME BLACKLIST EXTENSION |
3 | 3 | |
4 | 4 | Version 1.6 |
5 | | - © 2006 Rob Church |
| 5 | + © 2006-2007 Rob Church |
6 | 6 | |
7 | 7 | This is free software licensed under the GNU General Public License. Please |
8 | 8 | see http://www.gnu.org/copyleft/gpl.html for further details, including the |
— | — | @@ -58,8 +58,9 @@ |
59 | 59 | The example above would prevent creation of the user account "Foo", and any |
60 | 60 | account where the username contains "Bar" or "bar". |
61 | 61 | |
62 | | -You can comment out lines with #; this is useful for adding explanation as to |
63 | | -what a complicated regular expression will block, or for providing reasons. |
| 62 | +Lines without the list token (*) will be ignored when constructing the |
| 63 | +regular expression, which allows for adding comments or other explanations |
| 64 | +to the message page. |
64 | 65 | |
65 | 66 | == 5. Customising Warning Messages == |
66 | 67 | |
— | — | @@ -112,10 +113,13 @@ |
113 | 114 | 1.6 |
114 | 115 | Support multiple language translations |
115 | 116 | |
| 117 | +1.7 |
| 118 | + Ignore all non-list lines when constructing the regular expression |
| 119 | + |
116 | 120 | == 8. Thanks... == |
117 | 121 | |
118 | 122 | * Avar; whose other extensions provide better reference than the docs |
119 | 123 | * To the poster on mediawiki-l who inspired it |
120 | 124 | * Brion, for fixing a couple of bugs |
121 | 125 | |
122 | | - All feedback welcome via <robchur@gmail.com>. |
\ No newline at end of file |
| 126 | + All feedback welcome via <robchur@gmail.com>. |
Index: trunk/extensions/UsernameBlacklist/UsernameBlacklist.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | * |
7 | 7 | * @author Rob Church <robchur@gmail.com> |
8 | 8 | * @addtogroup Extensions |
9 | | - * @copyright © 2006 Rob Church |
| 9 | + * @copyright © 2006-2007 Rob Church |
10 | 10 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 |
11 | 11 | */ |
12 | 12 | |
— | — | @@ -86,12 +86,13 @@ |
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
90 | | - * Is the supplied text a comment? |
91 | | - * @param $text Text to check |
| 90 | + * Is the supplied text an appropriate fragment to include? |
| 91 | + * |
| 92 | + * @param string $text Text to validate |
92 | 93 | * @return bool |
93 | 94 | */ |
94 | | - function isComment( $text ) { |
95 | | - return substr( $this->transform( $text ), 0, 1 ) == '#'; |
| 95 | + function isUsable( $text ) { |
| 96 | + return substr( $text, 0, 1 ) == '*'; |
96 | 97 | } |
97 | 98 | |
98 | 99 | /** |
— | — | @@ -122,8 +123,8 @@ |
123 | 124 | if( $blacklist != '<usernameblacklist>' ) { |
124 | 125 | $lines = explode( "\n", $blacklist ); |
125 | 126 | foreach( $lines as $line ) { |
126 | | - $line = rtrim( $line ); |
127 | | - if( !empty( $line ) && !$this->isComment( $line ) ) |
| 127 | + $line = trim( $line ); |
| 128 | + if( $this->isUsable( $line ) ) |
128 | 129 | $groups[] = $this->transform( $line ); |
129 | 130 | } |
130 | 131 | return count( $groups ) ? '/(' . implode( '|', $groups ) . ')/u' : false; |