commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton" <niall.pember...@gmail.com>
Subject Re: isEscaped
Date Wed, 03 Sep 2008 14:56:00 GMT
On Tue, Sep 2, 2008 at 7:28 PM, Gabriel Reis <bielmooca@gmail.com> wrote:
> Hi,
>
> Is there any tool to verify if a String is escaped? Something like this:
>
> assertFalse( StringEscapeUtils.isHtmlEscaped("<b>text</b>") );
>
> assertTrue( StringEscapeUtils.isHtmlEscaped("&lt;b&gt;text&lt;/b&gt;")
);

Perhaps one way to do this is to use the StringEscapeUtils's
unescapeHtml() method and compare if the result equals the original.

something like...

if (value.equals(StringEscapeUtils.unescapeHtml(value))) {
    ...
}

http://commons.apache.org/lang/api-release/org/apache/commons/lang/StringEscapeUtils.html#unescapeHtml(java.lang.String)

Niall

> []s
> Gabriel
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message