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.
  • [get | view] (2009-03-01 11:39:57, 0.9 KB) [[attachment:1_9-devel_local_server_config.bundle]]
  • [get | view] (2007-07-27 20:50:57, 12.4 KB) [[attachment:IncludeWithAttachment20070727.py]]
  • [get | view] (2007-09-25 12:38:06, 18.2 KB) [[attachment:raphaelbossek.jpg]]
  • [get | view] (2007-08-15 20:55:02, 2.5 KB) [[attachment:test_parser_unicode.py]]
  • [get | view] (2007-07-27 20:49:55, 1.4 KB) [[attachment:text_xslt.patch]]
  • [get | view] (2007-08-10 20:44:42, 1.7 KB) [[attachment:text_xslt.py.txt]]
  • [get | view] (2007-08-09 20:16:03, 2.3 KB) [[attachment:utf8bug.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.