Package: jack
Version: 3.1.1-10
Severity: normal
Tags: patch

jacker's parser for its configuration files assumes that every hash (#)
starts a comment.  However, a hash can also be embedded in a variable,
for example in:
    unusable_chars:[' ', '#', '/'] # comment
Unfortunately, this leads to:
This is jack 3.1.1 (C)2004 Arne Zellentin <[EMAIL PROTECTED]>
Traceback (most recent call last):
  File "/usr/bin/jack", line 74, in ?
    user_cf = jack_rc.load(cf, cf['user_rc']['val'])
  File "/usr/lib/python2.3/site-packages/jack_rc.py", line 94, in load
    ret, val = jack_argv.parse_option(cf, i[0:2], 0, i[0], None, 
origin="rcfile")
  File "/usr/lib/python2.3/site-packages/jack_argv.py", line 145, in 
parse_option
    l = eval(data)
  File "<string>", line 1
    [' ', '
         ^
SyntaxError: EOL while scanning single-quoted string


Below is a patch which makes the parsing routing much more robust and deals
with hashes in variables.



--- jack_rc.py~ 2005-11-11 15:20:08.000000000 +0000
+++ jack_rc.py  2005-11-11 15:31:48.000000000 +0000
@@ -32,39 +32,43 @@
 
 def read(file):
     read_rc = []
-
     try:
         f = open(file)
-    except:
+    except (IOError, OSError):
         return read_rc
-
     lineno = 0
-    while 1:
-        x = f.readline()
+    for x in f.readlines():
+        lineno += 1
+        x = x.strip()
         if not x:
-            break
+            continue
         opt = val = com = None
-        lineno = lineno + 1
-
-        x = string.strip(x)
-        x = string.split(x, "#", 1)
-        if len(x) > 1:
-            opt, com = x
+        if x.startswith("#"):
+            com = x[1:].lstrip()
         else:
-            opt = x[0]
-        if opt and com:
-            opt = string.strip(opt)
-        if opt:
-            x = string.split(opt, ":", 1)
-            if len(x) > 1:
-                opt, val = x
-            else:
+            x = [i.strip() for i in x.split(":", 1)]
+            if len(x) < 2:
                 opt = x[0]
-        else:
-            opt = None
+            else:
+                opt, val = x
+                # check if there's a comment ridden in val
+                if "#" in val:
+                    quoted = []
+                    for i in range(len(val)):
+                        c = val[i]
+                        if c in ('"', "'") and (not i or val[i-1] != "\\"):
+                            if quoted and quoted[-1] == c:
+                                quoted.pop()
+                            else:
+                                quoted.append(c)
+                        elif c == "#" and not quoted:
+                            val, com = val[:i].strip(), val[i:].strip()
+                            break
         read_rc.append([opt, val, com, lineno])
     version = get_version(read_rc)
-    if version != jack_version.prog_rcversion:
+    if not version:
+        warning("config file %s doesn't define jackrc-version." % file)
+    elif version != jack_version.prog_rcversion:
         warning("config file %s is of unknown version %s." % (file, `version`))
     return read_rc
 
@@ -80,10 +84,9 @@
             return None
         if vers[0] != "jackrc-version":
             return None
-        ver = int(vers[1])
-        return ver
-    else:
-        return None
+        if vers[1].isdigit():
+            return int(vers[1])
+    return None
 
 def load(cf, file):
     rc = read(expand(file))




-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: powerpc (ppc)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.12-1-powerpc
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)

Versions of packages jack depends on:
ii  cdda2wav                  4:2.01+01a03-2 Creates WAV files from audio CDs
ii  cdparanoia                3a9.8-11       An audio extraction tool for sampl
ii  flac                      1.1.2-3        Free Lossless Audio Codec - comman
ii  python                    2.3.5-3        An interactive high-level object-o
ii  python-cddb               1.4-4          Python interface to CD-IDs and Fre
ii  python-eyed3              0.6.8-1        Python module for id3-tags manipul
ii  python-flac               0.0.4-1        Free Lossless Audio Codec [Python 
ii  python-pyvorbis           1.3-1          A Python interface to the Ogg Vorb
ii  vorbis-tools              1.0.1-1.5      Several Ogg Vorbis Tools

jack recommends no packages.

-- no debconf information

-- 
Martin Michlmayr
http://www.cyrius.com/


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to