mediawiki.ForeignStructuredUpload: Behave correctly when '=' appears in a description
authorBartosz Dziewoński <matma.rex@gmail.com>
Thu, 26 Nov 2015 18:36:18 +0000 (19:36 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Mon, 30 Nov 2015 16:48:20 +0000 (17:48 +0100)
We can't escape it (and we can't deal with '|'), because users might
expect these to accept wikitext.

Bug: T119691
Change-Id: I10df9ebab408f531812b653b36ed35570311935e

resources/src/mediawiki/mediawiki.ForeignStructuredUpload.js

index c336676..5e79039 100644 (file)
         * @return {string}
         */
        ForeignStructuredUpload.prototype.getDescriptions = function () {
-               var i, desc, templateCalls = [];
+               var i, desc, hasEquals, templateCalls = [];
 
                for ( i = 0; i < this.descriptions.length; i++ ) {
                        desc = this.descriptions[ i ];
-                       templateCalls.push( '{{' + desc.language + '|' + desc.text + '}}' );
+                       hasEquals = desc.text.indexOf( '=' ) !== -1;
+                       templateCalls.push( '{{' + desc.language + ( hasEquals ? '|1=' : '|' ) + desc.text + '}}' );
                }
 
                return templateCalls.join( '\n' );