Page MenuHomePhabricator

Global variable collision due to typo in local copy of Vega2 library
Closed, ResolvedPublicBUG REPORT

Description

There is an obvious typo at line 4933 in vega.js:

u.isString = function(obj) {
  return typeof value === 'string' || toString.call(obj) === '[object String]';
};

The type check should refer to the obj parameter instead of value. This caused an obscure bug on plwiki in conjunction with a local gadget leaking a global variable of the same name (reported here).

Event Timeline

PeterBowman renamed this task from Typo found in local copy of Vega2 library to Global variable collision due to typo in local copy of Vega2 library.Mar 16 2022, 11:57 PM

Change 771484 had a related patch set uploaded (by Peter Bowman; author: Peter Bowman):

[mediawiki/extensions/Graph@master] Fix a typo in Vega2 that can conflict with global variables

https://gerrit.wikimedia.org/r/771484

Looks like the bug still exists upstream: https://github.com/vega/datalib/blob/v1.9.3/src/util.js#L78 – I suggest also submitting a pull request there, so the fix doesn’t get lost with the next Vega upgrade.

Thank you, I have addressed this issue in https://github.com/vega/datalib/pull/112. Anyway, it seems that the repo is no longer maintained (see the note in their README.md) and now they resort to a different implementation at vega-util/isString.js.

Change 771484 merged by jenkins-bot:

[mediawiki/extensions/Graph@master] Fix a typo in Vega2 that can conflict with global variables

https://gerrit.wikimedia.org/r/771484