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:fr.aliasource.webmail.formatting.HTMLBodyFormatter.java

private String convert(String plain) {
    StringBuilder sb = new StringBuilder();
    String escaped = StringEscapeUtils.escapeHtml(plain);
    escaped = escaped.replaceAll("\r\n", "<br>");
    escaped = escaped.replaceAll("\n", "<br>");
    sb.append(escaped);//w ww  . j a  v a2 s . co m
    Pattern p = Pattern.compile(PATTERN_URL + "|" + PATTERN_EMAIL);
    Matcher m = p.matcher(sb);

    StringBuffer res = parseUrl(m, sb);
    if (res.toString().length() > 0) {
        return res.toString();
    } else {
        return sb.toString();
    }

}

From source file:com.igormaznitsa.sciareto.notifications.NotificationManager.java

public void showNotification(@Nullable final Image icon, @Nullable final String title, @Nonnull final Type type,
        @Nonnull final String message) {
    final JLabel label = new JLabel(String.format("<html>%s</html>", StringEscapeUtils.escapeHtml(message)));
    label.setForeground(Color.black);
    this.showNotification(icon, title, type, label);
}

From source file:com.sonymobile.backlogtool.NewEpicContainer.java

public String getThemeTitle() {
    return StringEscapeUtils.escapeHtml(themeTitle);
}

From source file:com.commsen.apropos.web.servlet.DownloadPropertiesServlet.java

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String name = req.getParameter("name");
    if (StringUtils.isBlank(name)) {
        resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Missing package name!");
        return;/*  w  w w .jav  a  2 s  . com*/
    }

    PropertyPackage propertyPackage = PropertiesManager.getPropertyPackage(name.trim());
    StringEscapeUtils.escapeHtml(name);
    if (propertyPackage == null) {
        resp.sendError(HttpServletResponse.SC_NOT_FOUND,
                "Property package called " + StringEscapeUtils.escapeHtml(name) + " was not found!");
        return;
    }

    String type = req.getParameter("type");
    if (StringUtils.isBlank(type)) {
        type = "properties";
    }

    if (type.toLowerCase().equals("properties")) {
        resp.setContentType("text/plain; charset=ASCI");
        propertyPackage.asProperties().store(resp.getOutputStream(),
                "Property file obtained from " + req.getLocalName());
    } else if (type.toLowerCase().equals("xml")) {
        resp.setContentType("text/xml; charset=UTF-8");
        propertyPackage.asProperties().storeToXML(resp.getOutputStream(),
                "Property file obtained from " + req.getRequestURI());
    } else {
        resp.sendError(HttpServletResponse.SC_BAD_REQUEST,
                "Unsupported type: " + StringEscapeUtils.escapeHtml(type) + " !");
        return;
    }

}

From source file:com.sangupta.velocity.directives.EscapeHtmlDirective.java

@Override
public boolean render(InternalContextAdapter context, Writer writer, Node node)
        throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
    String html = null;/*from   w  w  w .  j a v  a2  s . c  o  m*/

    if (node.jjtGetChild(0) != null) {
        html = String.valueOf(node.jjtGetChild(0).value(context));
    }

    if (AssertUtils.isEmpty(html)) {
        return true;
    }

    writer.write(StringEscapeUtils.escapeHtml(html));
    return true;
}

From source file:com.redhat.rhn.frontend.action.groups.DeleteGroupAction.java

/** {@inheritDoc} */
@Override//ww w  . ja  v  a2  s  .  c  om
public ActionForward execute(ActionMapping mapping, ActionForm formIn, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    RequestContext context = new RequestContext(request);
    ManagedServerGroup serverGroup = context.lookupAndBindServerGroup();
    if (context.isSubmitted()) {
        ServerGroupManager manager = ServerGroupManager.getInstance();
        manager.remove(context.getCurrentUser(), serverGroup);
        String[] params = { StringEscapeUtils.escapeHtml(serverGroup.getName()) };
        getStrutsDelegate().saveMessage(DELETED_MESSAGE_KEY, params, request);
        return mapping.findForward("success");
    }
    return mapping.findForward(RhnHelper.DEFAULT_FORWARD);
}

From source file:com.qualogy.qafe.gwt.server.ui.assembler.HTMLUIAssembler.java

public ComponentGVO convert(Component object, Window currentWindow, ApplicationMapping applicationMapping,
        ApplicationContext context, SessionContainer ss) {
    ComponentGVO vo = null;/*  ww  w  .  java 2s  .  co  m*/
    if (object != null) {
        if (object instanceof HTMLComponent) {
            HTMLComponent html = (HTMLComponent) object;
            HTMLGVO voTemp = new HTMLGVO();
            UIAssemblerHelper.copyFields(html, currentWindow, voTemp, applicationMapping, context, ss);
            String text = html.getHtml();
            if (html.getEscape()) {
                text = StringEscapeUtils.escapeHtml(text);
            }
            if (html.getPreformat()) {
                text = "<pre class=\"" + html.getStyleClass() + "\" style=\"" + html.getStyle() + "\">" + text
                        + "</pre>";
            }
            voTemp.setHtml(text);
            voTemp.setEscape(html.getEscape());
            vo = voTemp;
        }
    }
    return vo;
}

From source file:com.googlecode.jatl.HtmlBuilder.java

@Override
protected String escapeMarkup(String raw) {
    return StringEscapeUtils.escapeHtml(raw);
}

From source file:com.anite.penguin.form.Option.java

/**
 * Gets the value as a HTML Safe String
 * @return
 */
public String getHTMLSafeCaption() {
    return StringEscapeUtils.escapeHtml(this.caption);
}

From source file:com.apabi.qrcode.utils.EncodeUtils.java

/**
 * Html ?.
 */
public static String htmlEscape(final String html) {
    return StringEscapeUtils.escapeHtml(html);
}