Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed small security hole in bin/compile-messages.py by escaping the …

….po filename in os.system() call. Announcement forthcoming

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3592 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 518d406e53a7417385a1a2e10bb5110b67d28fac 1 parent 7c79f2a
Adrian Holovaty authored August 16, 2006

Showing 1 changed file with 8 additions and 1 deletion. Show diff stats Hide diff stats

  1. 9  django/bin/compile-messages.py
9  django/bin/compile-messages.py
@@ -19,7 +19,14 @@ def compile_messages():
19 19
             if f.endswith('.po'):
20 20
                 sys.stderr.write('processing file %s in %s\n' % (f, dirpath))
21 21
                 pf = os.path.splitext(os.path.join(dirpath, f))[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"'
23 30
                 os.system(cmd)
24 31
 
25 32
 if __name__ == "__main__":

0 notes on commit 518d406

Please sign in to comment.
Something went wrong with that request. Please try again.