comparison MoinMoin/wikiutil.py @ 332:0a40d8a4057e

fixed logfile breaking when DeletePage/RenamePage comment contains CRLF chars imported from: moin--main--1.5--patch-336
author Thomas Waldmann <tw@waldmann-edv.de>
date Sun, 18 Dec 2005 20:14:48 +0000
parents 76c964712b0f
children 7da3d0f49549
comparison
equal deleted inserted replaced
331:3fd688a3a370 332:0a40d8a4057e
237 s = s.replace("<", "&lt;") 237 s = s.replace("<", "&lt;")
238 s = s.replace(">", "&gt;") 238 s = s.replace(">", "&gt;")
239 if quote: 239 if quote:
240 s = s.replace('"', "&quot;") 240 s = s.replace('"', "&quot;")
241 return s 241 return s
242
243 def clean_comment(comment):
244 """ Clean comment - replace CR, LF, TAB by whitespace, delete control chars
245 TODO: move this to config, create on first call then return cached.
246 """
247 remap_chars = {
248 ord(u'\t'): u' ',
249 ord(u'\r'): u' ',
250 ord(u'\n'): u' ',
251 }
252 control_chars = u'\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0b\x0c\x0e\x0f' \
253 '\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f'
254 for c in control_chars:
255 remap_chars[c] = None
256 comment = comment.translate(remap_chars)
257 return comment
242 258
243 def make_breakable(text, maxlen): 259 def make_breakable(text, maxlen):
244 """ make a text breakable by inserting spaces into nonbreakable parts 260 """ make a text breakable by inserting spaces into nonbreakable parts
245 """ 261 """
246 text = text.split(" ") 262 text = text.split(" ")