Attachment 'utf8bug.py'
Download 1 # -*- coding: UTF-8 -*-
2 """
3 This macro is dedicated to reproduce a bug in 1.6/MoinMoin/parser/text_xslt.py.
4
5 This implementation base on the 1.6/MoinMoin/macro/Include.py but reduced to the
6 essential code to be able to reproduce the bug.
7 """
8
9 import StringIO
10 from MoinMoin import wikiutil
11 from MoinMoin.Page import Page
12
13 _sysmsg = '<p><strong class="%s">%s</strong></p>'
14
15 rawcontent = u"""<?xml version="1.0" encoding="UTF-8"?>
16 <Product xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="IVM" version="2.00" manufacturer="SIEMENS">
17 <!-- Sammelanschlußkennzahl -->
18 <!-- Bündel-Kennzahl -->
19 <!-- Automatisches Auflegen für Info- Mailbox -->
20 <!-- max. Mailbox- Länge -->
21 <!-- max. Länge einer ankommenden Nachricht in Sekunden -->
22 <!-- min. Länge einer ankommenden Nachricht in Sekunden -->
23 <!-- Länge des Mailbox- Passworts -->
24 <!-- Flag Gebührenmissbrauch verhindern -->
25 <!-- Automatisches Löschen von Nachrichten die Älter sind als angegeben (in Tagen) -->
26 </Product>"""
27
28 def execute(macro, text):
29 """
30 This function match the Include macro in main parts.
31
32 #ror = RedirectOutputRequest(macro.request)
33 #ror.start(sent_headers=True)
34 #try:
35 # cid = macro.request.makeUniqueID("Include_%s" % wikiutil.quoteWikinameURL(inc_page.page_name))
36 # inc_page.send_page(ror, content_only=1, content_id=cid, omit_footnotes=True)
37 # result.append(ror.getoutput())
38 #except UnicodeDecodeError, e:
39 # result.append(_sysmsg % ('error', _('Encoding %s error: %s' % (attach_encoding, e,))))
40 """
41 result = []
42 request = macro.request
43 _ = request.getText
44 fmt = macro.formatter.__class__(request)
45 fmt._base_depth = macro.formatter._base_depth
46 inc_page = Page(request, macro.formatter.page.page_name + 'utf8bug', formatter=fmt)
47 inc_page.set_body(rawcontent)
48
49 # output the included page
50 strfile = StringIO.StringIO()
51 request.redirect(strfile)
52 try:
53 cid = request.makeUniqueID("Include_%s" % wikiutil.quoteWikinameURL(inc_page.page_name))
54 inc_page.send_page(content_only=1, content_id=cid,
55 omit_footnotes=True)
56 result.append(strfile.getvalue())
57 except UnicodeDecodeError, e:
58 result.append(_sysmsg % ('error', _('Encoding error:') + e.__str__()))
59
60 request.redirect()
61
62 return ''.join(result)
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.