From 8824515e571eadd4a63b09e1331f35309315603f Mon Sep 17 00:00:00 2001 From: Santhosh Thottingal Date: Wed, 28 Mar 2012 11:25:45 +0530 Subject: [PATCH] Fix Bug 30681 - Wrong escaping for inexistent messages. - If the message does not exist, do an early return from the toString method, instead of going through replaceParameter and format comparisons. - Avoid getMessageText method. - If the format is plain, do not escape the angle brackets. Change-Id: I4561ee75d991ef8df3399ab17e5d75cb81f63f8f --- includes/Message.php | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/includes/Message.php b/includes/Message.php index 7357ed73a9..96ce7a9d5d 100644 --- a/includes/Message.php +++ b/includes/Message.php @@ -379,7 +379,15 @@ class Message { * @return String: HTML */ public function toString() { - $string = $this->getMessageText(); + $string = $this->fetchMessage(); + + if ( $string === false ) { + $key = htmlspecialchars( is_array( $this->key ) ? $this->key[0] : $this->key ); + if ( $this->format === 'plain' ) { + return '<' . $key . '>'; + } + return '<' . $key . '>'; + } # Replace parameters before text parsing $string = $this->replaceParameters( $string, 'before' ); @@ -561,19 +569,6 @@ class Message { return MessageCache::singleton()->transform( $string, $this->interface, $this->language, $this->title ); } - /** - * Returns the textual value for the message. - * @return Message contents or placeholder - */ - protected function getMessageText() { - $message = $this->fetchMessage(); - if ( $message === false ) { - return '<' . htmlspecialchars( is_array($this->key) ? $this->key[0] : $this->key ) . '>'; - } else { - return $message; - } - } - /** * Wrapper for what ever method we use to get message contents * -- 2.20.1