mozilla / pdf.js

PDF Reader in JavaScript
https://mozilla.github.io/pdf.js/
Apache License 2.0
48.33k stars 9.97k forks source link

JS code can contain toSource method #13289

Closed calixteman closed 1 year ago

calixteman commented 3 years ago

This method has only been implemented in Firefox but it has been deprecated and it isn't usable anymore: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toSource It isn't implemented in quickjs. Sadly, the function appears in some examples in the spec: https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/AcrobatDC_js_api_reference.pd and it's used in real life:

The code is still in mozilla-central: https://hg.mozilla.org/mozilla-central/file/9b7bac5af873863628d90e89299a813228ddbb83/js/src/vm/ToSource.cpp https://hg.mozilla.org/mozilla-central/file/9b7bac5af873863628d90e89299a813228ddbb83/js/src/builtin/Object.cpp#l271

I'm not sure that's a good idea to implement such a function...

marco-c commented 3 years ago

I have a set of almost 50k PDFs crawled from the web, and it looks like no one (except the one from #12593) is using toSource.

marco-c commented 3 years ago

I guess we can use https://github.com/marcello3d/node-tosource/blob/master/src/tosource.ts to implement it, but it shouldn't be a priority at all.

Snuffleupagus commented 1 year ago

Should we perhaps just WONTFIX this issue, given the problems outlined above and the fact that we've only seen a single example of this actually being used?