From bfc10fd7a6d9d91a2f234e42d4f3582e549bcdb5 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 14 Aug 2009 01:30:56 +0000 Subject: [PATCH] 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\'', --- includes/ConfEditor.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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' ) -- 2.20.1