Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chart.js (2,3,4,master) do not work on evironments loading also prototype.js #11201

Open
judovana opened this issue Mar 24, 2023 · 4 comments
Open

Comments

@judovana
Copy link

judovana commented Mar 24, 2023

Expected behavior

The chart.js library will render the chart even if prototype.js is loaded.

Current behavior

Reproducer page: https://jvanek.fedorapeople.org/charts/ ; namely: https://jvanek.fedorapeople.org/charts/impl/index4-umd-deprototyped.html

I maintain set of jenkins plugins, built around chartjs1. Finally (!) I kicked myself lot enough to port them to chart.js 4, thus I set this page to track the migration 1->2->3-4. At the end, I finished only 4, as it was very smooth.

Unluckily, when I finished the migration, I found the chart is not showing properly in jenkins, although identical page shows properly outside jenkins. I found, that loading of prototype.js http://prototypejs.org/ (in any version) is killing prototpye search in chart.js.

I debugged it to call of

  getPrototypeOf() {
      return Reflect.getPrototypeOf(scopes[0]);
    },

However, it seesm it is broken elsewhere, as without prototype.js scopes is array of length 2, but with prototype.js it is empty array. To found it reach over my JS skill.

Uncaught TypeError: `target` argument of Reflect.getPrototypeOf must be an object, got undefined
    getPrototypeOf helpers.config.js:57
    Ue helpers.config.js:181
    get helpers.config.js:205
    get helpers.config.js:120
    Xe helpers.config.js:188
    get helpers.config.js:119
    update core.controller.js:493
    wn core.controller.js:206
    <anonymous> index4-umd-deprototyped.html:89

Note, if you remove prototype.js from jenkins, the charts appear.But everything else case to work :)

Additional resources:

2017 mentions conflict with wordpress, solved by removal of prototype.js from project . Useless note, it is same trace I hit on chartj2 even with prototype.js 1.7
2018 mentions it on jenkinsci-dev group This mentions, update to 1.7.3 is fixing the issue. It did not worked for me
relevant to above. PR to bump jenkins protype.js from 1.7 to 1.7.3. Caused issues, was reverted, afaik jenkins is still on 1.7
2019 stackoweeflow exact issue (with possible solution)
2020, github issue for chartjs. Not 100% related, by mention security issues and is about same function
One of the few CVEs related to chart.js prototyep polution

Reproducible sample

https://jvanek.fedorapeople.org/charts/impl/index4-umd-deprototyped.html

Optional extra steps/info to reproduce

No response

Possible solution

No response

Context

No response

chart.js version

4.2.1

Browser name and version

latest firefox and chromium

Link to your project

https://github.com/judovana/jenkins-chartjs-plugin

@judovana
Copy link
Author

judovana commented Mar 24, 2023

Added also editable reproducert: https://jsfiddle.net/yvs6u3w9/ x https://jsfiddle.net/p3fmz5ty/
If yo remove <script src="https://jvanek.fedorapeople.org/charts/impl/prototypejs/prototype.js-1.7" type="text/javascript"></script> the chart will reappear (or opposite if you add it, then it will disapear)

@judovana judovana changed the title chart.js (2,3,4) do not work on evironments loading also prototype.js chart.js (2,3,4,master) do not work on evironments loading also prototype.js Mar 25, 2023
@judovana
Copy link
Author

judovana commented Mar 25, 2023

Had jsust checked against self built master of chart.js. Same issue

@judovana
Copy link
Author

judovana commented Mar 25, 2023

Have tried with tip of prototype.js; no change

@judovana
Copy link
Author

judovana commented Apr 3, 2023

for record: https://issues.jenkins.io/browse/JENKINS-70906

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant