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

iframe element with src="javascript:'<html></html>'" #1686

Closed
AlexzAK opened this issue Dec 22, 2016 · 6 comments
Closed

iframe element with src="javascript:'<html></html>'" #1686

AlexzAK opened this issue Dec 22, 2016 · 6 comments

Comments

@AlexzAK
Copy link

AlexzAK commented Dec 22, 2016

if I load html document containing

 <iframe ... src="javascript:'<html></html>'">
 </iframe>

jsdom fails with error

     Uncaught TypeError: contentWindow.eval is not a function
      at loadFrame (node_modules/jsdom/lib/jsdom/living/nodes/HTMLFrameElement-impl.js:75:19)
      at HTMLIFrameElementImpl._attach (node_modules/jsdom/lib/jsdom/living/nodes/HTMLFrameElement-impl.js:149:7)
      at HTMLDivElementImpl._attach (node_modules/jsdom/lib/jsdom/living/nodes/Node-impl.js:294:15)
      at HTMLDivElementImpl._attach (node_modules/jsdom/lib/jsdom/living/nodes/Element-impl.js:110:11)
      at HTMLDivElementImpl._attach (node_modules/jsdom/lib/jsdom/living/nodes/Node-impl.js:294:15)
      at HTMLDivElementImpl._attach (node_modules/jsdom/lib/jsdom/living/nodes/Element-impl.js:110:11)
      at HTMLDivElementImpl._attach (node_modules/jsdom/lib/jsdom/living/nodes/Node-impl.js:294:15)
      at HTMLDivElementImpl._attach (node_modules/jsdom/lib/jsdom/living/nodes/Element-impl.js:110:11)
      at HTMLBodyElementImpl._attach (node_modules/jsdom/lib/jsdom/living/nodes/Node-impl.js:294:15)
      at HTMLBodyElementImpl._attach (node_modules/jsdom/lib/jsdom/living/nodes/Element-impl.js:110:11)
      at HTMLHtmlElementImpl._attach (node_modules/jsdom/lib/jsdom/living/nodes/Node-impl.js:294:15)
      at HTMLHtmlElementImpl._attach (node_modules/jsdom/lib/jsdom/living/nodes/Element-impl.js:110:11)
      at DocumentImpl.insertBefore (node_modules/jsdom/lib/jsdom/living/nodes/Node-impl.js:227:22)
      at DocumentImpl.appendChild (node_modules/jsdom/lib/jsdom/living/nodes/Node-impl.js:334:17)
      at DocumentImpl.appendChild (node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:399:18)
      at setChild (node_modules/jsdom/lib/jsdom/browser/htmltodom.js:288:18)
      at HtmlToDom._parseWithparse5v1 (node_modules/jsdom/lib/jsdom/browser/htmltodom.js:90:7)
      at HtmlToDom.appendHtmlToDocument (node_modules/jsdom/lib/jsdom/browser/htmltodom.js:47:48)
      at setInnerHTML (node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:70:27)
      at DocumentImpl.write (node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:452:7)
      at Document.write (node_modules/jsdom/lib/jsdom/living/generated/Document.js:351:27)
      at Object.exports.jsdom (node_modules/jsdom/lib/jsdom.js:144:21)
      at processHTML (node_modules/jsdom/lib/jsdom.js:297:26)
      at resourceLoader.readFile (node_modules/jsdom/lib/jsdom.js:200:7)
      at ReadStream.readableStream.on (node_modules/jsdom/lib/jsdom/browser/resource-loader.js:76:7)
      at endReadableNT (_stream_readable.js:974:12)
      at _combinedTickCallback (internal/process/next_tick.js:74:11)
      at process._tickCallback (internal/process/next_tick.js:98:9)
@snuggs
Copy link
Contributor

snuggs commented Dec 25, 2016

@AlexzAK I'll take a look at it after Christmas.

Curious why the need for src="javascript:'<html></html>'. Could potentially be the issue.
What happens when not evaluating JS with the javascript: protocol.

@AlexzAK
Copy link
Author

AlexzAK commented Dec 25, 2016

@snuggs thanks, it is not a big problem, since I have workaround
But that html causes jsdom to fall, so it is a bug

I really don't understand why my target website uses src="javascript:'<html></html>' actually.
But I scraping it and have no control over it's code.

Same issue with

const {jsdom} = require('jsdom');
require("jsdom").defaultDocumentFeatures = {
  FetchExternalResources: false,
  ProcessExternalResources: false,
  SkipExternalResources: true
};

Not sure that I understand docs right. As far as I see, that config should disable JS

@manishwaran
Copy link

manishwaran commented May 20, 2017

+1

Any update on the issue ?

@domenic
Copy link
Member

domenic commented May 20, 2017

@domenic
Copy link
Member

domenic commented Jul 3, 2017

This should be fixed by 4b50320, which will be released shortly.

@domenic domenic closed this as completed Jul 3, 2017
@snuggs
Copy link
Contributor

snuggs commented Jul 3, 2017

Thanks @domenic 🙏

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

4 participants