Opened 19 years ago

Closed 19 years ago

Last modified 18 years ago

#488 closed defect (fixed)

[patch] removetags filter doesn't remove tags without a seperate ending tag

Reported by: ilikeprivacy@… Owned by: Adrian Holovaty
Component: Template system Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

the removetags filter incorrectly doesn't remove <br/> (possibly <img/> as well however I haven't tested).

I've included (sorry I'm unsure of the correct way to create and upload a patch, svn diff includes all my mods to other files) my modified filter which works, someone better with regular expressions can probably tweak the existing ones.

def removetags(value, tags):
    "Removes a space separated list of [X]HTML tags from the output"
    tags = [re.escape(tag) for tag in tags.split()]
    tags_re = '(%s)' % '|'.join(tags)
    starttag_re = re.compile('<%s(>|(\s+[^>]*>))' % tags_re)
    endtag_re = re.compile('</%s>' % tags_re)
    singletag_re = re.compile('<%s*/>' % tags_re)
    value = starttag_re.sub('', value)
    value = endtag_re.sub('', value)
    value = singletag_re.sub('', value)
    return value

Attachments (1)

removetags.patch (599 bytes ) - added by ilikeprivacy@… 19 years ago.
patch

Download all attachments as: .zip

Change History (4)

comment:1 by ilikeprivacy@…, 19 years ago

Component: Admin interfaceTemplate system

by ilikeprivacy@…, 19 years ago

Attachment: removetags.patch added

patch

comment:2 by ilikeprivacy@…, 19 years ago

Summary: removetags filter doesn't remove tags without a seperate ending tag[patch] removetags filter doesn't remove tags without a seperate ending tag

been a while... still broken :(

comment:3 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: newclosed

(In [1018]) Fixed #488 -- removetags template filter now removes tags without a space before the final slash

Note: See TracTickets for help on using tickets.
Back to Top