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

Fail to open Notebooks with custom HTML due to missing Javascript function isPlainObject #6199

Open
cholmcc opened this issue Oct 8, 2021 · 0 comments

Comments

@cholmcc
Copy link

cholmcc commented Oct 8, 2021

hi,

I have some older notebooks that I update from time to time. In those notebooks I do a bit of magic to manipulate cells and so on. That means I put in some HTML tags with a bit of JavaScript attached. However, lately, when I open up these notebooks I get the error message

Notebook failed to load
The error was:

TypeError: isPlainObject is not a function
See the error console for details.

Looking in the console I see that this happens when notebook.js tries to parse the HTML code - in particular if one uses attributes on some tags. To recreate this problem, make a notebook with a single Markdown cell with the content

<details ontoggle='console.log("Toggle")'>Details</details>

and save the notebook (I attach such a notebook too). Then try to open that notebook again and you should see the error message above. I tracked the error down to the function sanitizeHtml in static/notebook/main.min.js which calls the function isPlainObject on the attributes of a tag to see if that attribute is whitelisted. However, it never gets that far, since the function isPlainObject is apparently not defined at that point. The function isPlainObject is defined later in main.min.js as

module.exports = function isPlainObject(o) {
  var ctor, prot;
  if (isObjectObject(o) === false) return false; // If has modified constructor

  ctor = o.constructor;
  if (typeof ctor !== 'function') return false; // If has modified prototype

  prot = ctor.prototype;
  if (isObjectObject(prot) === false) return false; // If constructor does not have an Object-specific method

  if (prot.hasOwnProperty('isPrototypeOf') === false) {
    return false;
  } // Most likely a plain Object


  return true;
};

but is never "expoerted" to main.min.js (or at least too late).

This is running on Debian GNU/Linux "sid" with

  • python3-notebook 6.4.3-1
  • libjs-jquery 3.5.1+dfsg+~3.5.5-7
  • libjs-jquery-typeahead 2.11.0+dfsg1-2
  • libjs-jquery-ui 1.12.1+dfsg-8
  • python3 3.9.2-3
  • python3-ipykernel 5.5.5-2
  • python3-jupyter-client 6.1.12-1
  • python3-jupyter-core 4.8.0-1

using Google Chrome

Thank you.

Yours,

Christian
test.ipynb.gz

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

No branches or pull requests

1 participant