Page MenuHomePhabricator

HTML comments are stripped from site JavaScript (loaded via gen=js)
Closed, ResolvedPublic

Description

Author: wiki.warx

Description:
Below line from my Monobook.js:

var rex = new RegExp ('<!--' + 'hak dla skryptu' + '-->', 'i');

Is rendered as:

var rex = new RegExp ('', 'i');

In JavaScript loaded from wikipages.

This bug makes impossible to use HTML comments for making marks for AJAX code.


Version: 1.15.x
Severity: enhancement

Details

Reference
bz21303

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:56 PM
bzimport set Reference to bz21303.
bzimport added a subscriber: Unknown Object (MLST).

A temporary workaround is to use '<!' + '--'

wiki.warx wrote:

why '<--' + 'something' + '-->' is stripped and '<-' + '-something-' + '->' not?

Because it contains <!-- some text --> ; the parser doesn't look at quotes. Putting quotes, spaces and a plus in such a way that <!-- is no longer together works around it.

'<!--' + blah + '-->' is interpreted as quote comment quote
'<!' + '--' + blah + '--' + '>' doesn't have a special sequence

monobook.js is loaded via action=raw, it shouldn't "disappear". And in fact i see the content right in http://test.wikipedia.org/w/index.php?title=User:Platonides/monobook.js&action=raw&ctype=text/javascript&urid=243z2_79308
Where is it being removed?

wiki.warx wrote:

On my wiki it occurs only in site JavaScript (MediaWiki:Monobook.js) in user JS it's not stripped. It's same with and without extensions.

herd wrote:

monobook.js is loaded via action=raw, it shouldn't "disappear".

Actually, MediaWiki:Monobook.js is being loaded via gen=js (and combined with Common.js), which does do some limited parsing. This is a feature/bug in gen=js (and may be a dupe).

IAlex added a comment.Jan 14 2010, 7:39 PM

Fixed in r61058.