Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d31e391

Browse files
author
James Bennett
committed
0.91-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.91-bugfixes@3593 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent 0d60669 commit d31e391

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

django/bin/compile-messages.py

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

2633
if __name__ == "__main__":

0 commit comments

Comments
 (0)