Index: trunk/udplog/demux.py |
— | — | @@ -1,10 +1,11 @@ |
2 | 2 | # Simple python script for demultiplexing MediaWiki log files |
3 | 3 | |
4 | | -import sys, os, string |
| 4 | +import sys, os, string, re |
5 | 5 | |
6 | 6 | transTable = string.maketrans("./", "__") |
7 | 7 | openFiles = {} |
8 | | -baseDir = '/var/log/mw/udp'; |
| 8 | +baseDir = '/var/log/mw/udp' |
| 9 | +nameRegex = re.compile(r"^[\040-\176]*$") |
9 | 10 | |
10 | 11 | while True: |
11 | 12 | # Use readline() not next() to avoid python's buffering |
— | — | @@ -18,6 +19,11 @@ |
19 | 20 | # No name |
20 | 21 | continue |
21 | 22 | string.translate(name, transTable) |
| 23 | + |
| 24 | + # ASCII printable? |
| 25 | + if not nameRegex.match(name): |
| 26 | + continue |
| 27 | + |
22 | 28 | name += '.log' |
23 | 29 | try: |
24 | 30 | if name in openFiles: |