~ubuntu-branches/ubuntu/edgy/trac/edgy

« back to all changes in this revision

Viewing changes to trac/WikiFormatter.py

  • Committer: Bazaar Package Importer
  • Author(s): Stephan Hermann
  • Date: 2005-07-24 12:21:52 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050724122152-3xf8v1oqf2jcqk5n
Tags: 0.8.4-1ubuntu1
Resynchronise with Debian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
277
277
                        'linkname', 'macroname', 'macroargs', 'inline',
278
278
                        'modulename', 'moduleargs')
279
279
 
280
 
    _htmlproc_disallow_rule = re.compile('(?i)<(script|noscript|embed|object|iframe|frame|frameset|link|style|meta|param|doctype)')
 
280
    # Forbid "dangerous" HTML tags and attributes
 
281
    _htmlproc_disallow_rule = re.compile('(?i)<(script|noscript|embed|object|'
 
282
                                         'iframe|frame|frameset|link|style|'
 
283
                                         'meta|param|doctype)')
 
284
    _htmlproc_disallow_attribute = re.compile('(?i)<[^>]*\s+(on\w+)=')
281
285
 
282
286
    def default_processor(hdf, text, env):
283
287
        return '<pre class="wiki">' + util.escape(text) + '</pre>'
311
315
<div class="system-message">
312
316
 <strong>Error: HTML block contains disallowed tags.</strong>
313
317
 <pre>%s</pre>
314
 
</div>""" % util.escape(text)
 
318
</div>\n""" % util.escape(text)
 
319
            env.log.error(err)
 
320
            return err
 
321
        if Formatter._htmlproc_disallow_attribute.search(text):
 
322
            err = """\
 
323
<div class="system-message">
 
324
 <strong>Error: HTML block contains disallowed attributes.</strong>
 
325
 <pre>%s</pre>
 
326
</div>\n""" % util.escape(text)
315
327
            env.log.error(err)
316
328
            return err
317
329
        return text
378
390
        depth = int((len(fullmatch.group('idepth')) + 1) / 2)
379
391
        list_depth = len(self._list_stack)
380
392
        if list_depth > 0 and depth == list_depth + 1:
381
 
            self.in_list_item = True
 
393
            self.in_list_item = 1
382
394
        else:
383
395
            self.open_indentation(depth)
384
396
        return ''