Greg,
On 3/6/12 10:08 AM, Greg Thomas wrote:
On 6 March 2012 14:59, Christopher Schultz <chr...@christopherschultz.net> wrote:
It might be nice to (continue to) have CDATA optional. In that case, &&
would need to be escaped (along with other stuff, of course). I think we
only need to escape & < and >.
Why not simply use StringEscapeUtils.escapeXml() in commons-lang ?
That's actually what I am using. It turns out we have an
escapeJavascript method in the ValidatorTool class itself which replaces
things like ' " \t \n \r etc. Obviously that's not appropriate and so I
was just talking about the requirements, not necessarily the implementation.
My first stab at a patch ended up escaping everything including the
<script> start tag and end tags. Oops. So the solution is somewhat more
complex, but I'll get it.
Thanks,
-chris
PS The escapeJavascript method in ValidatorTool should probably be
replaced with a call to StringEscapeUtils.escapeJavascript (for VELTOOLS
2.0.x, which uses commons-lang 2.2 - 6 years old, by the way). For
commons-lang 3.x, we need StringEscapeUtils.escapeEcmaScript.