Bug 67693

Summary: Add option to pdfinfo to print javascript
Product: poppler Reporter: Adrian Johnson <ajohnson>
Component: utilsAssignee: poppler-bugs <poppler-bugs>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: Indicate of pdf contains javascript
print out javascript
print out javascript
indicate of pdf contains embedded files
indicate if pdf contains javascript
print out javascript
indicate if pdf contains javascript
print out javascript

Description Adrian Johnson 2013-08-03 02:27:14 UTC
The following patches make pdfinfo indicate if the pdf contains javascript and provide the option of printing all the javascript code in the pdf.
Comment 1 Adrian Johnson 2013-08-03 02:28:47 UTC
Created attachment 83560 [details] [review]
Indicate of pdf contains javascript

This patch adds an extra line to the pdfinfo output indicating if the pdf contains JavaScript.
Comment 2 Adrian Johnson 2013-08-03 02:30:16 UTC
Created attachment 83561 [details] [review]
print out javascript

This patch adds a "-js" option to pdfinfo that makes it print out all the JavaScript code in the pdf.

You can test it with these files:

09_r100pdf_a.pdf
animated-definite-integral.pdf
bug161327-2.pdf
bug230210.pdf
bug263803.pdf
bug302334_2.pdf
bug-poppler16762.pdf
bug-poppler17444.pdf
bug-poppler17901.pdf
bug-poppler18003.pdf
bug-poppler19915.pdf
bug-poppler20009.pdf
bug-poppler24036.pdf
bug-poppler9203.pdf
example_054.pdf
Comment 3 Adrian Johnson 2013-08-03 02:41:15 UTC
Created attachment 83562 [details] [review]
print out javascript

updated to fix a bug
Comment 4 Adrian Johnson 2013-08-03 02:51:02 UTC
Created attachment 83563 [details] [review]
indicate of pdf contains embedded files

It is also useful for pdfinfo to indicate of the pdf contains embedded files.
Comment 5 Albert Astals Cid 2013-08-04 19:05:35 UTC
The JSInfo object/api looks a bit weird, for example we parse the "WC" entry in actions there but nowhere else in our code. I would sincerely prefer if the parsing of stuff was in the objects it belongs to.

Do you think that's doable?
Comment 6 Adrian Johnson 2013-08-05 12:54:16 UTC
Created attachment 83662 [details] [review]
indicate if pdf contains javascript

Updated to move parsing out of JSInfo.
Comment 7 Adrian Johnson 2013-08-05 12:55:19 UTC
Created attachment 83663 [details] [review]
print out javascript

Updated to move parsing out of JSInfo.
Comment 8 Albert Astals Cid 2013-08-05 18:16:19 UTC
I think you "deprecated" the 'indicate of pdf contains embedded files' patch by mistake and then named one of the js patches as embedded files.

Want to fix that? Or maybe add the "embedded files" one to a different bug?
Comment 9 Albert Astals Cid 2013-08-16 22:59:12 UTC
After a review of the code i can't find anything wrong. The JSUtil* files seem like they belong more to utils/ than to poppler/ specially after the addition of the "Field Activated" things, that would not be much useful to an external program as they are untranslatable (maybe an enum and then the char * in pdfinfo makes more sense and then keep JSUtil* in poppler/)

Also, I understand you've run the new code over all the files and got no crashes because of the new code?
Comment 10 Adrian Johnson 2013-08-17 08:53:36 UTC
Created attachment 84163 [details] [review]
indicate if pdf contains javascript

I've updated the patches to move JSInfo.* into utils and checked that it runs on all the regtest files.
Comment 11 Adrian Johnson 2013-08-17 08:54:04 UTC
Created attachment 84164 [details] [review]
print out javascript
Comment 12 Albert Astals Cid 2013-08-17 14:12:01 UTC
Looks good to me. You have commiting rights, right? Maybe you can way a few days and if noone complains commit to master. Ah, and for the files make sure you add the line "this file is under gpl 2 or later" like we have on some other files that we have created from scratch.
Comment 13 Adrian Johnson 2013-08-24 05:36:20 UTC
I've added the GPL line and pushed to master.
Comment 14 kurt.pfeifle 2014-07-05 11:16:15 UTC
I only today discovered this new feature -- very useful, thank you very much.

Will be using it quite frequently from now, so thanks again.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.