Example usage for org.apache.commons.lang StringEscapeUtils escapeHtml

List of usage examples for org.apache.commons.lang StringEscapeUtils escapeHtml

Introduction

In this page you can find the example usage for org.apache.commons.lang StringEscapeUtils escapeHtml.

Prototype

public static String escapeHtml(String input) 

Source Link

Usage

From source file:com.careerly.utils.TextUtils.java

/**
 * xssHtml?//from  www.  j  av a  2s .c om
 *
 * @param text ??
 * @return ??
 */
public static String escapeHtml(String text) {
    return StringUtils.isBlank(text) ? StringUtils.EMPTY : StringEscapeUtils.escapeHtml(text);
}

From source file:ch.ksfx.web.pages.ViewConsoleForEntityPlain.java

@Secured({ "ROLE_ADMIN" })
public void onActivate(Long entityId, String entityType) {
    this.entityId = entityId;
    this.entityType = entityType;

    if (entityType.equals("activityInstance")) {
        console = StringEscapeUtils
                .escapeHtml(activityInstanceDAO.getActivityInstanceForId(entityId).getConsole());
    } else if (entityType.equals("publishingConfiguration")) {
        console = StringEscapeUtils/*  w  ww.  ja va 2 s.  c  om*/
                .escapeHtml(publishingConfigurationDAO.getPublishingConfigurationForId(entityId).getConsole());
    }
}

From source file:com.katsu.json.serializer.StringSerializer.java

private String escapeCharacter(String cad) {
    return StringEscapeUtils.escapeHtml(StringEscapeUtils.escapeJava(cad));
}

From source file:com.redhat.rhn.domain.action.errata.test.ErrataActionFormatterTest.java

/**
 * Tests getRelatedObjectDescription()./*from  w w  w  . j a  v a  2  s  .c om*/
 * @throws Exception if something bad happens
 */
public void testGetRelatedObjectDescription() throws Exception {
    ErrataAction action = (ErrataAction) ActionFactoryTest.createAction(user, ActionFactory.TYPE_ERRATA);
    ErrataActionFormatter formatter = new ErrataActionFormatter(action);

    Errata errata = action.getErrata().iterator().next();
    String expected = "<a href=\"/rhn/errata/details/Details.do?eid=" + errata.getId().toString() + "\">"
            + StringEscapeUtils.escapeHtml(errata.getAdvisory()) + "</a>";
    String result = formatter.getRelatedObjectDescription();

    assertTrue(result.contains(expected));
}

From source file:com.robin.reporter.Reporter.java

/**
 * Escapes HTML special characters./*from   w  w w  .j  a  v  a  2  s .c  o m*/
 * @param text any string that will appear in the HTML report
 * @return text where HTML characters are escaped
 */
public static String escapeHtml(final String text) {
    return StringEscapeUtils.escapeHtml(text);
}

From source file:com.redhat.rhn.domain.action.scap.ScapAction.java

/**
 * {@inheritDoc}/*from ww w  .  ja v a2  s  .com*/
 */
@Override
public String getHistoryDetails(Server server) {
    LocalizationService ls = LocalizationService.getInstance();
    StringBuilder retval = new StringBuilder();
    retval.append("</br>");
    retval.append(ls.getMessage("system.event.scapPath"));
    retval.append(StringEscapeUtils.escapeHtml(scapActionDetails.getPath()));
    retval.append("</br>");
    retval.append(ls.getMessage("system.event.scapParams"));
    retval.append(scapActionDetails.getParameters() == null ? ""
            : StringEscapeUtils.escapeHtml(scapActionDetails.getParametersContents()));
    if (this.getSuccessfulCount() > 0) {
        retval.append("</br>");
        retval.append("<a href=\"/rhn/systems/details/audit/XccdfDetails.do?sid=" + server.getId() + "&xid="
                + scapActionDetails.getId() + "\">");
        retval.append(ls.getMessage("system.event.scapDownload"));
        retval.append("</a>");
    }
    return retval.toString();
}

From source file:com.redhat.rhn.domain.action.PackageActionFormatter.java

/**
 * {@inheritDoc}/*from   w w  w .  j  a v a 2  s  .c o m*/
 */
@Override
@SuppressWarnings("unchecked")
public String getRelatedObjectDescription() {
    Set<PackageActionDetails> packages = ((PackageAction) this.getAction()).getDetails();
    List<String> result = new LinkedList<String>();
    if (packages != null) {
        for (PackageActionDetails packageDetail : packages) {
            result.add("<a href=\"/rhn/software/packages/Details.do?pid="
                    + packageDetail.getPackageId().toString() + "\">"
                    + StringEscapeUtils.escapeHtml(packageDetail.getPackageName().getName()) + "</a>");
        }
    }
    return StringUtil.join(", ", result);
}

From source file:edu.jdomengine.core.attr.JDomManyAttribute.java

/**
 * Adds a new token to the list.//  w w w . j av a2s  . c om
 * @param token the string to add to the list
 */
public void add(String token) {
    if (!(this.value == null || token.equals(IJDom.EMPTY_STRING) || this.value.equals(IJDom.EMPTY_STRING))) {
        this.value += this.separator + StringEscapeUtils.escapeHtml(token);
    }
}

From source file:com.redhat.rhn.domain.action.config.test.ConfigActionFormatterTest.java

/**
 * Tests getRelatedObjectDescription()./*from w  w w .  j a  v  a  2s. c om*/
 * @throws Exception if something bad happens
 */
public void testGetRelatedObjectDescription() throws Exception {
    ConfigAction action = (ConfigAction) ActionFactoryTest.createAction(user,
            ActionFactory.TYPE_CONFIGFILES_DEPLOY);
    ConfigActionFormatter formatter = new ConfigActionFormatter(action);

    ConfigRevision revision = action.getConfigRevisionActions().iterator().next().getConfigRevision();
    String expected = "<a href=\"/rhn/configuration/file/FileDetails.do?crid=" + revision.getId().toString()
            + "\">" + StringEscapeUtils.escapeHtml(revision.getConfigFile().getConfigFileName().getPath())
            + "</a>";
    String result = formatter.getRelatedObjectDescription();

    assertTrue(result.contains(expected));
}

From source file:mesquite.tol.lib.BaseHttpRequestMaker.java

public static boolean contactServer(String s, String URI, StringBuffer response) {
    HttpClient client = new HttpClient();
    GetMethod method = new GetMethod(URI);
    NameValuePair[] pairs = new NameValuePair[1];
    pairs[0] = new NameValuePair("build",
            StringEscapeUtils.escapeHtml("\t" + s + "\tOS =\t" + System.getProperty("os.name") + "\t"
                    + System.getProperty("os.version") + "\tjava =\t" + System.getProperty("java.version")
                    + "\t" + System.getProperty("java.vendor")));
    method.setQueryString(pairs);// w w w. j a  va 2  s  .com

    method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
            new DefaultHttpMethodRetryHandler(3, false));

    return executeMethod(client, method, response);
}