Code

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#2604 closed defect (fixed)

compile-messages.py fails on win32

Reported by: Jarosław Zabiełło Owned by: hugo
Component: Internationalization Version: master
Severity: normal Keywords: win32 i18n
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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 (0)

Change History (6)

comment:1 Changed 8 years ago 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).

comment:2 Changed 8 years ago 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"'

comment:3 Changed 8 years ago 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.

comment:4 Changed 8 years ago 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.

comment:5 Changed 8 years ago by mtredinnick

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

comment:6 Changed 8 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.