Hi Peter,
We've also just added a new feature to the unreleased Velocity 1.5 - a group
of event handlers to escape references. If you want to test it out,
download the nightly source snapshot from
http://cvs.apache.org/snapshots/velocity/ . Compile it. Then place the
following in your velocity.properties:
eventhandler.referenceinsertion.class =
org.apache.velocity.app.event.implement.EscapeHtmlReference
This will automatically apply HTML escaping to all references. Note this
feature was just added to the source and is not yet completely documented.
If you want only some reference handlers to be escaped you can use
Perl-style regular expressions
eventhandler.escape.html.match = /usertext.*/
Best,
WILL
----- Original Message -----
From: "Mike Kienenberger" <[EMAIL PROTECTED]>
To: "Velocity Users List" <[email protected]>
Sent: Tuesday, September 13, 2005 4:25 PM
Subject: Re: Escaping HTML control characters within velocity?
http://wiki.apache.org/jakarta-velocity/EscapeTool
Particularly,
http://svn.apache.org/viewcvs.cgi/jakarta/velocity/tools/trunk/src/java/org/apache/velocity/tools/generic/EscapeTool.java?view=markup
On 9/13/05, Peter Locke <[EMAIL PROTECTED]> wrote:
I display some text that may or may not contain html control characters
('<'
, '&', etc) - if it does contain them, I would like them to be converted
to
their 'safe' representations, such as '<' so that they display and
don't
alter the html . Is there a way to do this built into velocity? My
initial
thought was to create my own tool and use something like Spring's
HtmlUtils.htmlEscape(...), but I don't want to re-invent the wheel if it
is
already possible. As a side note, performance is critical; This method
will
theoretically be called on text on our main search results page, which has
a
huge number of hits daily, and I want to put as little additional strain
on
our application servers as possible.
Any feedback is appreciated.
--
Peter Locke
Senior Engineer / Dev Lead
www.abebooks.com <http://www.abebooks.com/>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]