Skip to content

Commit 6eefa52

Browse files
committed
0.90-fixes: Fixed minor security hole in compile-messages.py. See trunk patch in [3592]
git-svn-id: http://code.djangoproject.com/svn/django/branches/0.90-bugfixes@3594 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent 021e0c6 commit 6eefa52

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

django/bin/compile-messages.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
if file.endswith('.po'):
2020
sys.stderr.write('processing file %s in %s\n' % (file, dirpath))
2121
pf = os.path.splitext(os.path.join(dirpath, file))[0]
22-
cmd = 'msgfmt -o %s.mo %s.po' % (pf, pf)
22+
# Store the names of the .mo and .po files in an environment
23+
# variable, rather than doing a string replacement into the
24+
# command, so that we can take advantage of shell quoting, to
25+
# quote any malicious characters/escaping.
26+
# See http://cyberelk.net/tim/articles/cmdline/ar01s02.html
27+
os.environ['djangocompilemo'] = pf + '.mo'
28+
os.environ['djangocompilepo'] = pf + '.po'
29+
cmd = 'msgfmt -o "$djangocompilemo" "$djangocompilepo"'
2330
os.system(cmd)
2431

0 commit comments

Comments
 (0)