Hi,
I use Validator to check for some things such as XSS style attacks and HTML tags that I don't like in some content. @CheckXSS
In these cases, I need to filter this content and I'm doing that after the validation executes. However, the problems is that if I execute both a HTML Filter and a Length validator, the Lenght validator executes on the original textual content and not the filtered content and may therefore generate a constraint violation when it shouldn't.
Changing the order of the validation doesn't matter because it doesn't the filtering happens after validation. Ideally, I would change the field during the validation process. However, the field value is a copy of the original and not a reference itself. Besides, doing that seems like an ugly hack.
The most reasonable solution I can think of is to create a group interface(ChangeContent.class) and execute this validation before everything else, filter based on the results and then run normal validation. But that would mean adding that group interface to all @CheckXSS(groups={ChangeContent.class}) style tags. A bit ugly also.
Any better suggestions out there?
Kind regards, Marc
|