Django

Code

Ticket #2604 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

compile-messages.py fails on win32

Reported by: Jarosław Zabiełło Assigned to: hugo
Milestone: Component: Internationalization
Version: SVN Keywords: win32 i18n
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

compile-messages.py script is too much UNIX related so it does not work for Windows. Fixing is easy.

Instead of

os.environ['djangocompilemo'] = pf + '.mo'
os.environ['djangocompilepo'] = pf + '.po'
cmd = 'msgfmt -o "$djangocompilemo" "$djangocompilepo"'

it should be

cmd = 'msgfmt -o "%s" "%s"' % (pf + '.mo', pf + '.po')

Attachments

Change History

08/26/06 09:53:02 changed by ubernostrum

Your suggested patch is how it actually used to be, except that creates a security vulnerability; a malicious user with knowledge of how most shells work could -- if you didn't pay attention to the name of the file you were compiling -- cause arbitrary shell commands to be executed by giving the file a creative name. See this entry in the official Django blog for details: http://www.djangoproject.com/weblog/2006/aug/16/compilemessages/.

The correct solution here is to check which platform we're on and use that to determine whether variables are referenced using a dollar sign (for Unix) or a percent sign (for Windows).

08/26/06 16:14:12 changed by Jarosław Zabiełło

Good point. Here is never version:

Instead of

cmd = 'msgfmt -o "$djangocompilemo" "$djangocompilepo"'

it should be:

if sys.platform == 'win32':
    cmd = 'msgfmt -o "%djangocompilemo%" "%djangocompilepo%"'
else:
    cmd = 'msgfmt -o "$djangocompilemo" "$djangocompilepo"'

08/26/06 16:35:49 changed by mtredinnick

We cannot universally make this change; this is the small security problem that was fixed recently (see the svn log message for the last change to that file to see the problem we are fixing). So somebody with detailed Windows shell knowledge needs to work out a similar fix. Reverting the change is not the (complete) solution.

08/26/06 16:46:45 changed by ubernostrum

Malcolm, from what I understand of Windows scripting, Jaroslaw's second suggestion would work; Windows shell variables are referenced by preceding and trailing percent signs.

08/26/06 16:59:34 changed by mtredinnick

Yeah, you're right, thinking about it. Sorry, I'm Windows-clueless.

08/28/06 13:43:59 changed by adrian

  • status changed from new to closed.
  • resolution set to fixed.

(In [3672]) Fixed #2604 -- Got compile-messages.py working on win32. Thanks for the patch, Jaros?\197?\130aw Zabie?\197?\130?\197?\130o


Add/Change #2604 (compile-messages.py fails on win32)




Change Properties
Action