File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,17 @@ 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
+ if sys .platform == 'win32' : # Different shell-variable syntax
30
+ cmd = 'msgfmt -o "%djangocompilemo%" "%djangocompilepo%"'
31
+ else :
32
+ cmd = 'msgfmt -o "$djangocompilemo" "$djangocompilepo"'
23
33
os .system (cmd )
24
34
25
35
if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments