Browse Source

Code Injection Fix

rparedis 2 years ago
parent
commit
325880f46e
4 changed files with 8 additions and 4707 deletions
  1. 3 2
      src/pypdevs/accurate_time.py
  2. 3 1
      src/pypdevs/simulator.py
  3. 2 0
      src/pypdevs/util.py
  4. 0 4704
      test/devstrace.xml

+ 3 - 2
src/pypdevs/accurate_time.py

@@ -2,10 +2,11 @@ import time as python_time
 import sys
 
 def time():
-    if sys.platform == "win32":
+    if sys.version_info[0] == 2 and sys.platform == "win32":
+        # better precision on windows, but deprecated since 3.3
         return python_time.clock()
     else:
-        return python_time.time()
+        return python_time.perf_counter()
 
 def sleep(t):
     python_time.sleep(t)

+ 3 - 1
src/pypdevs/simulator.py

@@ -47,6 +47,8 @@ except ImportError:
 try:
     import Queue as Queue
 except ImportError:
+    # Fix for parallel DEVS?
+    # from multiprocessing import Queue
     import queue as Queue
 
 def local(sim):
@@ -69,7 +71,7 @@ def loadCheckpoint(name):
     """
     listdir = os.listdir('.')
     if str(name) + "_SIM.pdc" not in listdir:
-        # Simulator object not even found, don't bother continueing
+        # Simulator object not even found, don't bother continuing
         #assert info("Not even a SIM file was found for the requested name, giving up already")
         return
     try:

+ 2 - 0
src/pypdevs/util.py

@@ -124,6 +124,8 @@ def easyCommand(function, args):
     for i in range(len(args)):
         if i != 0:
             text += ", "
+        if isinstance(args[i], str):
+            args[i] = '"%s"' % args[i][1:-1].replace('"', "\\\"").replace("'", "\\'")
         text += str(args[i])
     text += ")"
     return text

File diff suppressed because it is too large
+ 0 - 4704
test/devstrace.xml