Selaa lähdekoodia

Parsing environment= now allows characters commonly found in paths to be in an unquoted value.

Mike Naberezny 15 vuotta sitten
vanhempi
commit
3e1d49d8ad
3 muutettua tiedostoa jossa 26 lisäystä ja 2 poistoa
  1. 16 1
      CHANGES.txt
  2. 4 1
      src/supervisor/datatypes.py
  3. 6 0
      src/supervisor/tests/test_datatypes.py

+ 16 - 1
CHANGES.txt

@@ -1,11 +1,26 @@
 Next release
 
+  - When parsing "environment=" in the config file, changes introduced in
+    3.0a8 prevented Supervisor from parsing some characters commonly
+    found in paths unless quoting was used as in this example:
+    
+      environment=HOME='/home/auser'
+    
+    Supervisor once again allows the above line to be written as:
+    
+      environment=HOME=/home/auser
+
+    Alphanumeric characters, "_", "/", ".", "+", "-", "(", and ")" can all be
+    used as a value without quoting. If any other characters are neeed in the
+    value, please quote it as in the first example above.  Thanks to Paul 
+    Heideman for reporting this issue.
+
   - Supervisor will now look for its config file in locations relative to the
     executable path, allowing it to be used more easily in virtual 
     environments.  If sys.argv[0] is '/path/to/venv/bin/supervisorctl', 
     supervisor will now look for it's config file in 
     '/path/to/venv/etc/supervisord.conf' and '/path/to/venv/supervisord.conf'
-    in addition to the other standard locations.
+    in addition to the other standard locations.  Patch by Chris Rossi.
 
 3.0a8 (2010-01-20)
 

+ 4 - 1
src/supervisor/datatypes.py

@@ -84,7 +84,10 @@ def dict_of_key_value_pairs(arg):
     """ parse KEY=val,KEY2=val2 into {'KEY':'val', 'KEY2':'val2'}
         Quotes can be used to allow commas in the value
     """
-    tokens = list(shlex.shlex(arg))
+    lexer = shlex.shlex(arg)
+    lexer.wordchars += '/.+-()'
+    
+    tokens = list(lexer)
     tokens_len = len(tokens)
 
     D = {}

+ 6 - 0
src/supervisor/tests/test_datatypes.py

@@ -115,6 +115,12 @@ class DatatypesTest(unittest.TestCase):
         expected = {'foo': 'bar,baz', 'baz': 'q,ux'}
         self.assertEqual(actual, expected)
 
+    def test_dict_of_key_value_pairs_handles_unquoted_non_alphanum(self):
+        actual = datatypes.dict_of_key_value_pairs(
+            'HOME=/home/auser,FOO=/.foo+(1.2)-_/')
+        expected = {'HOME': '/home/auser', 'FOO': '/.foo+(1.2)-_/'}
+        self.assertEqual(actual, expected)
+
     def test_dict_of_key_value_pairs_allows_trailing_comma(self):
         actual = datatypes.dict_of_key_value_pairs('foo=bar,')
         expected = {'foo': 'bar'}