[texworks] Scripting read access

Paul A Norman paul.a.norman at gmail.com
Sat Dec 4 23:30:26 CET 2010


What about something like just one check box for all  read / write -

1. Allow scripts to Access Disk

And one for the

2. python lua plugins

which if ticked automatically ticks the 1. above and leaves 1. greyed
out until 2. is unticked by the User again?


On 5 December 2010 11:16, Paul A Norman <paul.a.norman at gmail.com> wrote:
> Thanks Stefan, I'll download your latest later and have a go.
> I have been using the fileOpen functions to open all sub documents
> when using a master document, there's been a script up on your script
> Issues page for quite a few months now.
> Its sort of useful especially when you need to search through all
> documents - they all need to be open before the search starts. Or when
> you  just want to position the cursor and open a sub document. (Select
> between braces, get selected text, construct full path, open document)
> If the user has  allowed scripts to read documents from disk - could
> we make these script functions for actually opening Tw documents work
> on the same User's check box preference selection? Perhaps
> automatically allowing same target and script and sub directories as
> for the readFile function itself?
> There would be other times when it is very useful to be able to open
> Tw document(s) from script for user editing.
> Be sad to loose this functionality.
> Or if we are pulling this out of Scripting - could we add a Tw File
> menu item for Open File at cursor then? And another one for  open all
> \include etc documents?
> Or allow ALL things of this perceived security issue nature to be
> doable if  "use script plugins" is ticked by the User, as after all
> the script plugins automatically open the Pandora's box of security
> issues wide open any way don't they?
> Sort of a Master switch for all these things in a way isn't it?
> It would seem counter intuitive that read or write scripts be turned
> off, and script plugins be
> turned on letting python and Lua then do things that QtScript can then
> not do - seems confusing?
> Paul
> On 5 December 2010 04:24, Stefan Löffler <st.loeffler at gmail.com> wrote:
>> Hi,
>> what has been promised for a while is done in a version draft: a
>> TW.readFile function. Calling it is simple:
>> res = TW.readFile("path/to/file.txt");
>> The return value res is a map with one or two properties. res.status
>> gives you the status code (same as for writeFile). Upon success
>> (res.status == 0), there's also res.result which contains the text of
>> the file.
>> In lua, these things are access the same way. In Python, they are
>> accessed as a dictionary (res['status']).
>> There's also a setting for reading in the preferences dialog. By
>> default, global reading is disabled. Files in the folder containing the
>> current script (e.g., <resources>/scripts/test/) and its subfolders as
>> always readable, as are files in the folder containing the current
>> target (tex/pdf) file's directory, its root file's directory (if
>> available), and their subfolders.
>> IMPORTANT NOTE: the workaround so far - namely, using TW.app.openFile -
>> has been disabled for security reasons. So if your script accesses
>> files, you will need to change them (slightly).
>> Also, there's no way anymore to open new windows without the user's
>> interaction (there's still TW.app.open, but no TW.app.openFile anymore).
>> I don't consider this particularly important, but if you disagree we may
>> be able to come up with something that respects permissions...
>> As always, please test ;).
>> HTH
>> Stefan

More information about the texworks mailing list