Page MenuHomePhabricator

Pipe trick applied to user and Gadget JS breaks the JS
Open, Needs TriagePublic

Description

If you have a script like

function a () {
	return '[[' + a + '|]]';
}

and save it to a JS page, it will be silently be converted to:

function a () {
	return '[[' + a + '|' + a + ']]';
}

This is another symptom of T10761, but it's more insidious (certainly extremely confusing and annoying because:

  • It actually changes the Javascript without any warning
    • Furthermore, if you paste in the original JS and click "show changes", you see no changes so it's really surprising that the JS that's saved is not what you just pasted in.
  • The result is not necessarily equivalent: if a is File:a.jpg, then [[File:a.jpg|]] is not the same thing as [[File:a.jpg|File:a.jpg]].

So it can (and did) break Gadgets.

This is even more annoying in this case:

function has_side_effects () {
	// a side effect happens here
}

function a () {
	var a = '[[' + has_side_effects() '|]]';
}

where you actual end up saving:

function a () {
	var a = '[[' + has_side_effects() '|' + has_side_effects() ']]';
}

Event Timeline

Inductiveload renamed this task from Pipe trick applied to user and Gadget JS to Pipe trick applied to user and Gadget JS breaks the JS.Apr 4 2021, 2:53 PM