r49590 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49589‎ | r49590 | r49591 >
Date:05:00, 17 April 2009
Author:tstarling
Status:deferred
Tags:
Comment:
Restrict name characters to printable ASCII, to avoid crashing logrotate
Modified paths:
  • /trunk/udplog/demux.py (modified) (history)

Diff [purge]

Index: trunk/udplog/demux.py
@@ -1,10 +1,11 @@
22 # Simple python script for demultiplexing MediaWiki log files
33
4 -import sys, os, string
 4+import sys, os, string, re
55
66 transTable = string.maketrans("./", "__")
77 openFiles = {}
8 -baseDir = '/var/log/mw/udp';
 8+baseDir = '/var/log/mw/udp'
 9+nameRegex = re.compile(r"^[\040-\176]*$")
910
1011 while True:
1112 # Use readline() not next() to avoid python's buffering
@@ -18,6 +19,11 @@
1920 # No name
2021 continue
2122 string.translate(name, transTable)
 23+
 24+ # ASCII printable?
 25+ if not nameRegex.match(name):
 26+ continue
 27+
2228 name += '.log'
2329 try:
2430 if name in openFiles:

Status & tagging log