Last modified: 2014-11-13 22:54:41 UTC
original bug title: mediawiki.jqueryMsg double escapes HTML entities when using mw.message(key).parse() on a message containing a link ---- how to reproduce: mw.loader.using('mediawiki.jqueryMsg', function() { mw.messages.set({ simple: '→', subst: '→ $1 $2 $3', wlink: '[$1 linktext] $2 → $3' }); console.log(mw.message('simple').parse()); >> → console.log(mw.message('subst', 'a', 'b', 'c').parse()); >> → a b c console.log(mw.message('wlink', 'a', 'b', 'c').parse()); >> <a href="a">linktext</a> b &rarr; c ISSUE: ---------------------------^ }); Expected result: console.log(mw.message('wlink', 'a', 'b', 'c').parse()); >> <a href="a">linktext</a> b → c
Running example: mw.loader.using('mediawiki.jqueryMsg', function() { mw.messages.set({ simple: '→', subst: '→ $1 $2 $3', wlink: '[$1 linktext] $2 → $3' }); console.log(mw.message('simple').parse()); >> → console.log(mw.message('subst', 'a', 'b', 'c').parse()); >> → a b c console.log(mw.message('wlink', 'a', 'b', 'c').parse()); >> <a href="a">linktext</a> b &rarr; c //ISSUE: -------------------------^ });
Cf. https://www.mediawiki.org/wiki/Manual:Messages_API#Output_modes_and_escaping
Confirmed still happening. However, I think the others are underescaping rather that the last one overescaping.
(In reply to Niklas Laxström from comment #3) > Confirmed still happening. However, I think the others are underescaping > rather that the last one overescaping. I think the others are okay and the last one is over-escaping. → is valid wikitext for a right arrow (it's part of the subset of HTML that is allowed). Since it's valid wikitext, it should be allowed in parse mode. [http://example.com linktext] b → c renders to: <a rel="nofollow" class="external text" href="http://example.com">linktext</a> b → c (see https://en.wikipedia.org/w/index.php?title=User:Mattflaschen_(WMF)/Sandbox&oldid=632518564) which is equivalent to (and renders the same as): <a rel="nofollow" class="external text" href="http://example.com">linktext</a> b → c
Do we have concrete examples? Perhaps I have one, from UploadWizard: 2014-10-31 10.16 < Nemo_bis> tgr: Descrivi sinteticamente tutto quanto sia degno di nota a proposito di quest'opera. Per le foto, indica le cose principali che vi sono rappresentate, l'occasione e/o il luogo in cui sono state scattate. 2014-10-31 10.16 < Nemo_bis> (overescaping in UW)
That works fine for me. It doesn't seem to use entities (https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FUploadWizard.git/077fc02922ae8023c54b78528195c4c7a77da5a3/i18n%2Fit.json#L191). ::1> @var_export( wfMessage( 'mwe-upwiz-tooltip-description' )->inLanguage( 'it' )->parse() ); @var_export( wfMessage( 'mwe-upwiz-tooltip-description' )->inLanguage( 'it' )->parse() ); 'Descrivi sinteticamente tutto quanto sia degno di nota a proposito di quest\'opera. Per le foto, indica le cose principali che vi sono rappresentate, l\'occasione e/o il luogo in cui sono state scattate.' --- mw.message( 'mwe-upwiz-tooltip-description' ).parse() "Descrivi sinteticamente tutto quanto sia degno di nota a proposito di quest'opera. Per le foto, indica le cose principali che vi sono rappresentate, l'occasione e/o il luogo in cui sono state scattate." --- However, I assume the report is valid; that just doesn't seem to be an example.