Last modified: 2014-11-13 22:54:41 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T55576, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 53576 - mediawiki.jqueryMsg double escapes HTML entities when using mw.message(key).parse() on a message containing a link
mediawiki.jqueryMsg double escapes HTML entities when using mw.message(key).p...
Status: NEW
Product: MediaWiki
Classification: Unclassified
Internationalization (Other open bugs)
unspecified
All All
: High normal (vote)
: ---
Assigned To: Nobody - You can work on this!
leteam?
:
Depends on:
Blocks: 53540
  Show dependency treegraph
 
Reported: 2013-08-30 08:40 UTC by Rainer Rillke @commons.wikimedia
Modified: 2014-11-13 22:54 UTC (History)
7 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Rainer Rillke @commons.wikimedia 2013-08-30 08:40:33 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 &amp;rarr; c
ISSUE: ---------------------------^
});

Expected result:
  console.log(mw.message('wlink', 'a', 'b', 'c').parse());
  >> <a href="a">linktext</a> b &rarr; c
Comment 1 Rainer Rillke @commons.wikimedia 2013-08-30 08:43:15 UTC
Running example:

mw.loader.using('mediawiki.jqueryMsg', function() {
  mw.messages.set({ simple: '&rarr;', subst: '&rarr; $1 $2 $3', wlink: '[$1
linktext] $2 &rarr; $3' });
  console.log(mw.message('simple').parse());
  >> &rarr;
  console.log(mw.message('subst', 'a', 'b', 'c').parse());
  >> &rarr; a b c
  console.log(mw.message('wlink', 'a', 'b', 'c').parse());
  >> <a href="a">linktext</a> b &amp;rarr; c
//ISSUE: -------------------------^
});
Comment 2 Rainer Rillke @commons.wikimedia 2013-08-30 08:44:50 UTC
Cf. https://www.mediawiki.org/wiki/Manual:Messages_API#Output_modes_and_escaping
Comment 3 Niklas Laxström 2014-10-16 10:55:10 UTC
Confirmed still happening. However, I think the others are underescaping rather that the last one overescaping.
Comment 4 Matthew Flaschen 2014-11-05 05:28:32 UTC
(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.  &rarr; 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 &rarr; 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 &rarr; c
Comment 5 Nemo 2014-11-05 08:32:28 UTC
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&#039;opera. Per le foto, indica le cose principali che vi sono rappresentate, l&#039;occasione e/o il luogo in cui sono state scattate.
2014-10-31 10.16 < Nemo_bis> (overescaping in UW)
Comment 6 Matthew Flaschen 2014-11-13 22:53:03 UTC
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.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links