from trac.core import *
from trac.web.api import ITemplateStreamFilter
from trac.ticket.api import ITicketManipulator
from genshi.filters.transform import Transformer, StreamBuffer

class EvaluationFieldHider(Component):
    """Hides and protects evaluation field."""

    implements(ITemplateStreamFilter,ITicketManipulator)

    # ITemplateStreamFilter methods

    def filter_stream(self, req, method, filename, stream, data):
        if filename == 'ticket.html':
            filter = Transformer('//label[@for="field-evaluation"]')
            stream |= filter.remove()
            filter = Transformer('//select[@id="field-evaluation"]')
            stream |= filter.remove()
        return stream

    # ITicketManipulator methods

    def prepare_ticket(self, req, ticket, fields, actions):
        pass

    def validate_ticket(self, req, ticket):
        if ticket['evaluation'] != '' and req.args.get('action') != 'evaluate':
            return [('evaluation', 'field is protected')]
        return []

@@ -865,16 +865,15 @@
  if 
-ticket%5B'
+'field_
 eval
@@ -883,56 +883,20 @@
 ion'
-%5D != '' and req.args.get('action') != 'evaluate'
+ in req.args
 :%0A  

Improve protection