Scatter/Gather thoughts

by Johan Petersson

JavaScript Acrobatics

When you disable the JavaScript support in Adobe Acrobat or Acrobat Reader, you get this somewhat confusing warning every time the application exits:

This document contains JavaScripts. Do you want to enable JavaScripts from now on? The document may not behave correctly if they're disabled.

Let's try to ignore the error in the message text (you don't pluralize a language name) and focus on the error causing it to be shown. This message is obviously supposed to notify the user of potential problems when opening a PDF document with embedded scripts, but it is in fact shown whenever you quit the application. The warning is likely triggered by some internal use of JavaScript.

I'm not the first person to investigate this bug (which isn't fixed in version 7.0.1, by the way): Richard Griswold was sufficiently annoyed to create patches for the Acrobat 7.0 ECMAScript plugin, EScript.api. His patches, which are distributed as Perl scripts, will replace the code to display the message with NOP instructions.

It looks like the patch for the Windows version would work for Acrobat 7.0.1 too (I don't think that plugin was updated), but I try to avoid patching binary files for problems such as this. In this case I wouldn't have to create the patch myself, but I may need a new patch for the next application update and I don't want to rely on a third party to provide it. I had to modify an Internet Explorer binary in order to get around its "Your current security settings prohibit running ActiveX" messages, but I prefer simpler solutions when possible. Features like self-repairing applications and Windows File Protection also have a tendency to get in the way.

Maybe there's a less intrusive solution? One way would be to disable the JavaScript plugin entirely (the plugin is loaded even if you disable JavaScript support through the settings). Attempting this revealed that several other plugins depends on EScript.api, including an automatic update function I'd like to keep.

Next I tried tracking process file accesses while exiting Acrobat and found a likely culprit. On application exit the file glob.settings.js was written to a JavaScripts subdirectory in Acrobat's application data directory:

\Documents and Settings\<login>\Application Data\Adobe\Acrobat\7.0\

glob.settings.js is not actually a JavaScript file, despite the .js suffix. I guess it just contains JavaScript-related settings. Removing the file or the JavaScripts subdirectory turns out to remove the error message, but only during the next exit because the file is recreated if not found.

There's a simple trick that'll often work when Windows applications insist on running or loading files you don't want them to (and recreating them): keep the file around, but deny all access to it through file system permissions. Perhaps surprisingly, many applications will ignore access denied errors rather than complaining about them.

To deny all access, right-click the abovementioned JavaScripts directory, then uncheck "Allow inheritable permissions from parent to propagate to this object" under the Security tab, choose Remove, and click OK. You'll see a warning about denying everyone access, click Yes.

There could be unforeseen problems, but with this change JavaScript is still shown as disabled in Acrobat and the exit warning message is gone, so it appears to be an easy workaround for the bug.

10 April, 2005