Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I get security warning message "This file contains potentially unsafe dynamic content" in this construct

I am finally able to reproduce this message that I get once in a while.

This in on V8.04, on windows 7.

While trying things, I found how to make Mathematica generate the above message when I open a notebook with Manipulate in it.

First the error message screen:

enter image description here

I now hit 'enable dynamics' and all seems well. But each time I reopen the notebook, I get the message again. (One must close M, and start up again, and then open the notebook to see the message).

So I do not understand this warning message, and why it comes up, and what I need to change in the code to remove it.

The code to generate it is:

Manipulate[

  DynamicModule[{p},
   p["x"] = 0;
   Row[{Dynamic[
      Refresh[p["x"]++; Row[{"p[x]=", p["x"]}],
       TrackedSymbols -> {n}]]}]
   ],

  Button["update counter", n++],
  {{n,0}, None}
  ]

The above is on its own notebook, with nothing else in the notebook.

I close M, then start it, then open the notebook, and I see the above message.

Now, I thought initially that to remove the message, I need to change p["x"] to p[x] so I closed the above notebook, and made a new notebook with this code:

Manipulate[

  DynamicModule[{p},
   p = 0;
   Row[{Dynamic[Refresh[p++; Row[{"p=", p}], TrackedSymbols -> {n}]]}]
   ],

  Button["update counter", n++],
  {{n, 0}, None}
  ]

Then closed M, and started it again, and opened the above notebook, and now I did not see the warning message. But when I repeated the process, I saw the same error come back.

(I posted this question to the Math group, but that is slow, and my post has not even shown up there, but in that post I said that the error went away when I changed p["x"] to p[x], because it actually did at first, but when I later tried it, the message came back, which I do not understand why)

p["x"] is an indexed object as explained in this page:

http://reference.wolfram.com/mathematica/tutorial/MakingDefinitionsForIndexedObjects.html

The question is: What is in the above code makes this warning to show up? Am I writing something wrong in the above example?

Code runs OK after I enable dynamics. Btw, I am opening this notebook from the same folder I open all my other notebooks, nothing changed and this is on home PC, no networks share folder and nothing out of the ordinary.

Here is the related link to notebook security

http://reference.wolfram.com/mathematica/tutorial/NotebookSecurity.html

I do not see in the above anything related to what I am doing. All what I can say, it has to do with the use of DynamicModule[] inside Manipulate, which is itself a DynamicModule. But I do not understand this well enough to figure why this is a problem.

Update 1

I do not see how this has anything to do with path. I can remove the error by simply commenting out the inner Dynamic like this:

Manipulate[


 (*
   DynamicModule[{p},
   p["x"]=0;
   Row[{Dynamic[Refresh[p["x"]++;Row[{"p[x]=",p["x"]}],TrackedSymbols-> \
   {n}]]}]
   ],
 *)

 n,
 Button["update counter", n++],
 {{n, 0}, None}
 ]

Save the notebook, close M, start M, open the notebook. Error went away.

So, it is in the code.

Update 2

Trying to reproduce what Yoda reported in his answer, I am not able to.

  1. make new notebook, type Dynamic@DateString[]
  2. ENTER to evaluate.
  3. SAVE
  4. close M
  5. open M
  6. open notebook
  7. no error

enter image description here

Update dec 21, 2001

On the Math Group, John Fultz was kind enough to reply to my post, I do not think he will mind if I post his answer here for the benefit of others to see

> > So, why is using p["x"] causing the security warning message?

That is a bug, which has already been fixed in development sources.
John Fultz
User Interface Group
Wolfram Research, Inc.

Sorry that I do not have a link to include to his reply, I could not find a link on google now. I use thunderbird to read newsgroups.

Should now this question remain open? Or should it be closed? If I need to close it, I can accept one of the answers so it is closed.

like image 856
Nasser Avatar asked Dec 20 '11 23:12

Nasser


1 Answers

This is not because of the particular code sample, but rather due to Mathematica's security features. From tutorial/NotebookSecurity,

When the user opens a notebook containing dynamic content, Mathematica will first determine whether the notebook's directory is trusted, untrusted, or neither.

  • If the notebook's directory is trusted, the notebook will be allowed to automatically perform dynamic evaluations without alerting the user.
  • If the notebook's directory is untrusted, the user will be alerted upon any attempt by the notebook to perform dynamic evaluations.
    enter image description here

By default, only $InstallationDirectory, $BaseDirectory, and $UserBaseDirectory are "trusted". In addition, there are a set of directories that are always untrusted (can be changed). These are your downloads
The solution now, is to add your current working directory to the list of trusted folders.

Go to Preferences > Advanced > Open Options Inspector and under Global Preferences, start searching for trusted and you should see the three options pop up. You can add them here.

enter image description here

like image 73
abcd Avatar answered Sep 27 '22 21:09

abcd