Ignore:
Timestamp:
6 Apr 2016, 08:51:19 (8 years ago)
Author:
Henrik Bettermann
Message:

Forbid style and script elements in html fields.

See r13235.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/interfaces.py

    r13135 r13805  
    1919from zope import schema
    2020from waeup.ikoba.interfaces import (
    21     IIkobaObject, validate_id,
     21    IIkobaObject, validate_id, validate_html,
    2222    ContextualDictSourceFactoryBase)
    2323from waeup.ikoba.interfaces import MessageFactory as _
     
    9898        title = _(u'Multilingual content in HTML format'),
    9999        required = False,
     100        constraint=validate_html,
    100101        )
    101102
  • main/waeup.ikoba/trunk/src/waeup/ikoba/interfaces.py

    r13803 r13805  
    142142    return True
    143143
     144# Define a validation method for HTML fields
     145class NotHTMLValue(schema.ValidationError):
     146    __doc__ = u"Style or script elements not allowed"
     147
     148def validate_html(value):
     149    if '<style' in value or '<script' in value:
     150        raise NotHTMLValue(value)
     151    return True
     152
     153
    144154# Define a validation method for international phone numbers
    145155class InvalidPhoneNumber(schema.ValidationError):
     
    585595        required = False,
    586596        default = default_html_frontpage,
     597        constraint=validate_html,
    587598        )
    588599
Note: See TracChangeset for help on using the changeset viewer.