r38256 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r38255‎ | r38256 | r38257 >
Date:21:23, 30 July 2008
Author:simetrical
Status:old
Tags:
Comment:
Delete Cite::validateName(). Use Xml::escapeId() instead. All parser tests pass.
Modified paths:
  • /trunk/extensions/Cite/Cite_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Cite/Cite_body.php
@@ -155,7 +155,7 @@
156156 return $this->error( 'cite_error_ref_numeric_key' );
157157 }
158158
159 - #Split these into groups.
 159+ # Split these into groups.
160160 if( $group === null ) {
161161 $group = $default_group;
162162 }
@@ -195,14 +195,14 @@
196196 else if ( $cnt >= 1 ) {
197197 if ( isset( $argv['name'] ) ) {
198198 // Key given.
199 - $key = $this->validateName( $argv['name'] );
 199+ $key = Sanitizer::escapeId( $argv['name'] );
200200 unset( $argv['name']);
201201 --$cnt;
202202 }
203203 if ( isset( $argv['group'] ) ){
204204 if (! $wgAllowCiteGroups ) return array(false); //remove when groups are fully tested.
205205 // Group given.
206 - $group = $argv['group'];//don't apply validateName for group display
 206+ $group = $argv['group'];
207207 unset( $argv['group']);
208208 --$cnt;
209209 }
@@ -217,32 +217,6 @@
218218 // No key
219219 return array(null,$group);
220220 }
221 -
222 - /**
223 - * Since the key name is used in an XHTML id attribute, it must
224 - * conform to the validity rules. The restriction to begin with
225 - * a letter is lifted since references have their own prefix.
226 - *
227 - * @fixme merge this code with the various section name transformations
228 - * @fixme double-check for complete validity
229 - * @return string if valid, false if invalid
230 - */
231 - function validateName( $name ) {
232 - if( preg_match( '/^[A-Za-z0-9:_.-]*$/i', $name ) ) {
233 - return $name;
234 - } else {
235 - // WARNING: CRAPPY CUT AND PASTE MAKES BABY JESUS CRY
236 - $text = urlencode( str_replace( ' ', '_', $name ) );
237 - $replacearray = array(
238 - '%3A' => ':',
239 - '%' => '.'
240 - );
241 - return str_replace(
242 - array_keys( $replacearray ),
243 - array_values( $replacearray ),
244 - $text );
245 - }
246 - }
247221
248222 /**
249223 * Populate $this->mRefs based on input and arguments to <ref>

Status & tagging log