From: Brion Vibber Date: Fri, 14 Aug 2009 01:30:56 +0000 (+0000) Subject: Added trim() call to work around mystery bug where whitespace gets appended to single... X-Git-Tag: 1.31.0-rc.0~40317 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=bfc10fd7a6d9d91a2f234e42d4f3582e549bcdb5;p=lhc%2Fweb%2Fwiklou.git 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\'', --- diff --git a/includes/ConfEditor.php b/includes/ConfEditor.php index 9c8ebb6c5f..d8b3da851d 100644 --- a/includes/ConfEditor.php +++ b/includes/ConfEditor.php @@ -306,11 +306,17 @@ class ConfEditor { function parseScalar( $str ) { if ( $str !== '' && $str[0] == '\'' ) // Single-quoted string - return strtr( substr( $str, 1, -1 ), + // @fixme trim() call is due to mystery bug where whitespace gets + // appended to the token; without it we ended up reading in the + // extra quote on the end! + return strtr( substr( trim( $str ), 1, -1 ), array( '\\\'' => '\'', '\\\\' => '\\' ) ); if ( $str !== '' && @$str[0] == '"' ) // Double-quoted string - return stripcslashes( substr( $str, 1, -1 ) ); + // @fixme trim() call is due to mystery bug where whitespace gets + // appended to the token; without it we ended up reading in the + // extra quote on the end! + return stripcslashes( substr( trim( $str ), 1, -1 ) ); if ( substr( $str, 0, 4 ) == 'true' ) return true; if ( substr( $str, 0, 5 ) == 'false' )