* Show --batch-size option in help of maintenance scripts that support it
* (bug 4381) Magic quotes cleaning is not comprehensive, key strings not
unescaped
+* (bug 30684) Fix bad escaping in mw.message for inexistent messages (i.e. <key>)
=== API changes in 1.19 ===
* (bug 19838) siprop=interwikimap can now use the interwiki cache.
* @return string Message as a string in the current form or <key> if key does not exist.
*/
toString: function() {
+
if ( !this.map.exists( this.key ) ) {
- // Return <key> if key does not exist
+ // Use <key> as text if key does not exist
+ if ( this.format !== 'plain' ) {
+ // format 'escape' and 'parse' need to have the brackets and key html escaped
+ return mw.html.escape( '<' + this.key + '>' );
+ }
return '<' + this.key + '>';
}
var text = this.map.get( this.key ),
});
test( 'mw.message & mw.messages', function() {
- expect(16);
+ expect(17);
ok( mw.messages, 'messages defined' );
ok( mw.messages instanceof mw.Map, 'mw.messages instance of mw.Map' );
var goodbye = mw.message( 'goodbye' );
strictEqual( goodbye.exists(), false, 'Message.exists returns false for inexisting messages' );
- equal( goodbye.toString(), '<goodbye>', 'Message.toString returns <key> if key does not exist' );
+ equal( goodbye.plain(), '<goodbye>', 'Message.toString returns plain <key> if format is "plain" and key does not exist' );
+ // bug 30684
+ equal( goodbye.escaped(), '<goodbye>', 'Message.toString returns properly escaped <key> if format is "escaped" and key does not exist' );
});
test( 'mw.msg', function() {
- expect(2);
+ expect(3);
+
+ ok( mw.messages.set( 'hello', 'Hello <b>awesome</b> world' ), 'mw.messages.set: Register' );
equal( mw.msg( 'hello' ), 'Hello <b>awesome</b> world', 'Gets message with default options (existing message)' );
equal( mw.msg( 'goodbye' ), '<goodbye>', 'Gets message with default options (inexisting message)' );