Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#2604 closed defect (fixed) 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 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')

Change History (6)

comment:1 Changed 9 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:

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 9 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%"'
    cmd = 'msgfmt -o "$djangocompilemo" "$djangocompilepo"'

comment:3 Changed 9 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 9 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 9 years ago by mtredinnick

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

comment:6 Changed 9 years ago by adrian

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

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

Note: See TracTickets for help on using tickets.
Back to Top