Skip to content

Fixed Error in FES prevents message from being shown, Prevented 'window' properties from being overwritten #7765

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

Merged
merged 3 commits into from
Apr 22, 2025

Conversation

HughJacks
Copy link

Resolves #7678

Changes:

Added a list of protected properties in main.js to prevent p5 from overriding certain window properties:

Added a check for hasOwnProperty in fes_core.js to prevent inherited properties like constructor from causing errors:

Changed core/main.js from:

      // Attach its properties to the window
      for (const p in this) {
        if (this.hasOwnProperty(p)) {
          if(p[0] === '_') continue;
          bindGlobal(p);
        }
      }

to:

      const protectedProperties = ['constructor', 'length'];
      // Attach its properties to the window
      for (const p in this) {
        if (this.hasOwnProperty(p)) {
          if(p[0] === '_' || protectedProperties.includes(p)) continue;
          bindGlobal(p);
        }
      }

Changed core/friendly_errors/fes_core.js from:

        if (
          fxns.[lowercase] &&
          !context[fxns[lowercase]] &&
          typeof context[prop] === 'function'
        ) {

to:

        if (
          fxns.hasOwnProperty(lowercase) &&
          !context[fxns[lowercase]] &&
          typeof context[prop] === 'function'
        ) {

Screenshots of the change:

PR Checklist

HughJacks and others added 3 commits April 20, 2025 14:11
Prevented window.constructor and window.length from being overwritten in bindGlobal
Copy link

welcome bot commented Apr 21, 2025

🎉 Thanks for opening this pull request! Please check out our contributing guidelines if you haven't already. And be sure to add yourself to the list of contributors on the readme page!

Copy link
Contributor

@davepagurek davepagurek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix, looks good!

@davepagurek davepagurek merged commit eac15d9 into processing:dev-2.0 Apr 22, 2025
2 checks passed
@davepagurek
Copy link
Contributor

@all-contributors please add @HughJacks for code

Copy link
Contributor

@davepagurek

I've put up a pull request to add @HughJacks! 🎉

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

Successfully merging this pull request may close these issues.

2 participants