r54991 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54990‎ | r54991 | r54992 >
Date:01:30, 14 August 2009
Author:brion
Status:ok
Tags:
Comment:
Added trim() call to work around mystery bug where whitespace gets appended to single or double-quoted string tokens; without it we ended up reading in the extra quote on the end as if it were part of the string.

Examples from reading in extension .i18n files:
- 'quiz_reset' => 'Reset',
+ 'quiz_reset' => 'Reset"',

- 'very-special-message' => 'Aren\'t I special?',
+ 'very-special-message' => 'Aren\'t I special?"
+ ',

- 'nss-db-error' => 'Error reading from authentication database',
+ 'nss-db-error' => 'Error reading from authentication database\'',
Modified paths:
  • /trunk/phase3/includes/ConfEditor.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ConfEditor.php
@@ -306,11 +306,17 @@
307307 function parseScalar( $str ) {
308308 if ( $str !== '' && $str[0] == '\'' )
309309 // Single-quoted string
310 - return strtr( substr( $str, 1, -1 ),
 310+ // @fixme trim() call is due to mystery bug where whitespace gets
 311+ // appended to the token; without it we ended up reading in the
 312+ // extra quote on the end!
 313+ return strtr( substr( trim( $str ), 1, -1 ),
311314 array( '\\\'' => '\'', '\\\\' => '\\' ) );
312315 if ( $str !== '' && @$str[0] == '"' )
313316 // Double-quoted string
314 - return stripcslashes( substr( $str, 1, -1 ) );
 317+ // @fixme trim() call is due to mystery bug where whitespace gets
 318+ // appended to the token; without it we ended up reading in the
 319+ // extra quote on the end!
 320+ return stripcslashes( substr( trim( $str ), 1, -1 ) );
315321 if ( substr( $str, 0, 4 ) == 'true' )
316322 return true;
317323 if ( substr( $str, 0, 5 ) == 'false' )

Status & tagging log