List of usage examples for org.apache.commons.lang StringEscapeUtils escapeHtml
public static String escapeHtml(String input)
From source file:com.medallia.tiny.string.StringTemplateBuilder.java
/** Make a StringTemplate from the given template string */ public StringTemplate go(String template) { StringTemplate st;/*from w ww. ja va 2 s. c o m*/ if (symbolNotFoundListener != null) { st = new StringTemplate(template, DefaultTemplateLexer.class) { @Override public Object get(StringTemplate self, String attribute) { Object o = super.get(self, attribute); if (self == this && o == null) { symbolNotFoundListener.symbolNotFound(attribute); } return o; } }; } else { st = new StringTemplate(template, DefaultTemplateLexer.class); } st.setAttributes(attr); st.setErrorListener(ExplodingStringTemplateErrorListener.LISTENER); if (escapeHtml) { st.registerRenderer(String.class, new SimpleAttributeRenderer() { public String toString(Object o) { return StringEscapeUtils.escapeHtml(String.valueOf(o)); } }); } return st; }
From source file:com.predic8.membrane.core.interceptor.groovy.GroovyInterceptor.java
@Override public String getLongDescription() { StringBuilder sb = new StringBuilder(); sb.append(TextUtil.removeFinalChar(getShortDescription())); sb.append(":<br/><pre style=\"overflow-x:auto\">"); sb.append(StringEscapeUtils.escapeHtml(TextUtil.removeCommonLeadingIndentation(src))); sb.append("</pre>"); return sb.toString(); }
From source file:com.activecq.api.helpers.DesignHelper.java
/** * Returns an img tag for the image path supplied in the path parameter. * * @param path/*w w w . j a va2 s .c om*/ * @param page * @param attrs * @return */ public static String imgTag(String path, Page page, Map<String, String> attrs) { String src = imgSrc(path, page); if (StringUtils.isBlank(src)) { return "<!-- Missing Image : " + path + " -->"; } if (attrs == null) { attrs = new HashMap<String, String>(); } // Image alt if (!attrs.containsKey("alt")) { attrs.put("alt", ""); } // Begin writing img tag String html = "<img src=\"" + StringEscapeUtils.escapeHtml(src) + "\""; for (String key : attrs.keySet()) { final String attr = StringEscapeUtils.escapeHtml(StringUtils.stripToEmpty(attrs.get(key))); html += " " + key + "=\"" + attr + "\""; } html += "/>"; return html; }
From source file:com.siberhus.web.ckeditor.Ckeditor.java
public String renderFileBrowser() { StringBuilder outb = new StringBuilder(); outb.append("<a href="); outb.append("\""); outb.append(renderFileBrowserLink()); outb.append("\" "); if (this.tagConfig.target != null) { outb.append("target="); outb.append("\""); outb.append(this.tagConfig.target); outb.append("\" "); }//from w ww.jav a 2 s . c om outb.append(">"); outb.append(StringEscapeUtils.escapeHtml(this.initialValue)); outb.append("</a>"); return outb.toString(); }
From source file:com.edmunds.etm.rules.impl.AgentConfigurationManager.java
private List<String> getActiveRuleSetLines(BufferedReader reader) throws IOException { final List<String> lines = Lists.newArrayList(); String line = reader.readLine(); while (line != null) { line = line.replaceAll("\\|", " | "); // allow line breaks in long regex rules lines.add(StringEscapeUtils.escapeHtml(line)); line = reader.readLine();/*w ww. j a v a 2 s. c o m*/ } return lines; }
From source file:com.alibaba.jstorm.ui.controller.ZookeeperController.java
@RequestMapping(value = UIDef.API_V2 + "/zookeeper/node/data", produces = "application/json;") @ResponseBody//from ww w . j a v a 2 s. co m public Map<String, Object> getData(@RequestParam String path, String clusterName) { clusterName = StringEscapeUtils.escapeHtml(clusterName); String data = ZookeeperManager.getZKNodeData(clusterName, path); Map<String, Object> map = new HashMap<>(); map.put("data", data); return map; }
From source file:com.fluidops.iwb.util.UIUtil.java
/** * Composes a text span for the value showing * - for URIs: display name (in italic font) and the URI (in brackets, if different from the display name), both underlined * - for literals: the value itself/*from ww w. ja v a 2 s .co m*/ * When hovering over the span, a tooltip is shown, containing the info about datatype and actual value. * Currently used to show the existing values in the edit mode in the triple editor. */ public static String getSpanWithTooltipAndDisplayName(Value value) { String label = EndpointImpl.api().getDataManager().getLabel(value); String tooltip = createKeyValueTooltip(value); tooltip = StringEscapeUtils.escapeHtml(tooltip); if (value instanceof URI) { String displayUri = AutoCompletionUtil.toDisplayValue(value); StringBuilder text = new StringBuilder("<u>"); if (!label.equals(displayUri) && !label.equals(value.stringValue())) { text.append("<i>"); text.append(StringEscapeUtils.escapeHtml(label)); text.append("</i> ("); text.append(displayUri); text.append(")"); } else { text.append(StringEscapeUtils.escapeHtml(label)); } text.append("</u>"); return getSpan(text.toString(), tooltip); } else { label = StringEscapeUtils.escapeHtml(label); label = label.replace("\n", "<br/>"); return getSpan(label, tooltip); } }
From source file:com.predic8.membrane.core.util.HttpUtil.java
private static String getHTMLErrorBody(String text, String comment) { StringBuilder buf = new StringBuilder(256); buf.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \r\n" + " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\r\n" + "<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n" + "<head>\r\n" + "<title>Internal Server Error</title>\r\n" + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\r\n" + "<style><!--\r\n" + "body { font-family:sans-serif; } \r\n" + ".footer { margin-top:20pt; color:#AAAAAA; padding:1em 0em; font-size:10pt; }\r\n" + ".footer a { color:#AAAAAA; }\r\n" + ".footer a:hover { color:#000000; }\r\n" + "--></style>" + "</head>\r\n" + "<body><h1>Internal Server Error</h1>"); buf.append("<hr/>"); buf.append("<p>While processing your request, the following error was detected. "); buf.append(comment);/*from w ww . j a v a 2 s .c o m*/ buf.append("</p>\r\n"); buf.append("<pre id=\"msg\">"); buf.append(StringEscapeUtils.escapeHtml(text)); buf.append("</pre>"); buf.append("<p class=\"footer\">"); buf.append(Constants.HTML_FOOTER); buf.append("</p>"); buf.append("</body>"); return buf.toString(); }
From source file:io.hops.hopsworks.common.util.FormatUtils.java
public static String stdoutToHtml(String text) { String html = StringEscapeUtils.escapeHtml(text); html = html.replaceAll("\n", "<br>"); html = html.replaceAll("\t", StringUtils.repeat(" ", 8)); html = html.replaceAll(" ", StringUtils.repeat(" ", 1)); return html;/* ww w.j a v a2 s . c o m*/ }
From source file:de.fhg.fokus.openride.services.favoritepoint.FavoritePointService.java
@GET @Produces("text/json") public Response getFavoritePoints(@Context HttpServletRequest con, @PathParam("username") String username) { System.out.println("getFavoritePoints start"); // check if remote user == {username} in path param // if (!username.equals(con.getRemoteUser())) { // return Response.status(Response.Status.FORBIDDEN).build(); // }// ww w . ja v a2 s .c o m CustomerEntity c = customerControllerBean.getCustomerByNickname(username); // build a List of Objects that shall be available in the JSON context. ArrayList list = new ArrayList(); list.add(new FavoritePointResponse()); XStream x = Utils.getJasonXStreamer(list); ArrayList favoritePoints = new ArrayList(); List<FavoritePointEntity> favPoints = (List<FavoritePointEntity>) favoritePointControllerBean .getFavoritePointsByCustomer(c); FavoritePointResponse response; for (FavoritePointEntity point : favPoints) { response = new FavoritePointResponse(); response.setFavptId(point.getFavptId()); response.setFavptDisplayName(StringEscapeUtils.escapeHtml(point.getFavptDisplayname())); response.setFavptAddress(StringEscapeUtils.escapeHtml(point.getFavptAddress())); response.setFavptGeoCoords(StringEscapeUtils.escapeHtml(point.getFavptPoint())); favoritePoints.add(response); } System.out.println(favoritePoints.size() + " favoritepoints to return"); return Response.ok(x.toXML(favoritePoints)).build(); }