List of usage examples for org.apache.commons.lang3 StringEscapeUtils escapeHtml4
public static final String escapeHtml4(final String input)
Escapes the characters in a String using HTML entities.
For example:
"bread" & "butter"
"bread" & "butter"
.
From source file:com.khs.sherpa.parser.StringParamParser.java
private String applyEncoding(String value, String format) { String result = value;//w w w . j av a 2 s. c o m if (format != null) { if (format.equals(Encode.XML)) { result = StringEscapeUtils.escapeXml(value); } else if (format.equals(Encode.HTML)) { result = StringEscapeUtils.escapeHtml4(value); } else if (format.equals(Encode.CSV)) { result = StringEscapeUtils.escapeCsv(value); } } return result; }
From source file:com.technophobia.substeps.glossary.HTMLSubstepsPublisher.java
private static void buildStepTagRows(final StringBuilder buf, final Collection<StepDescriptor> infos) { for (final StepDescriptor info : infos) { log.debug("info non escaped: " + info.getExpression() + "\n\tescaped:\n" + StringEscapeUtils.escapeHtml4(info.getExpression())); buf.append(String.format(TABLE_ROW_FORMAT, StringEscapeUtils.escapeHtml4(info.getExpression()), info.getExample(), StringEscapeUtils.escapeHtml4(info.getDescription()))).append("\n"); }/* w ww . j av a 2s . c om*/ }
From source file:entity.Direction.java
public String getNameForShop() { return StringEscapeUtils.escapeHtml4(nameForShop); }
From source file:com.ibm.ids.example.ShowResult.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { String safename = StringEscapeUtils.escapeHtml4(request.getParameter("name")); Locale locale = request.getLocale(); ResourceBundle messages = ResourceBundle.getBundle("com.ibm.ids.example.Messages", locale); response.setContentType("text/html"); PrintWriter out = response.getWriter(); // log what we received in a vulnerable way try {//from w w w .ja va 2 s .c o m writeToVulnerableSink(getVulnerableSource(safename)); } catch (Exception e) { // ignore this, we're just logging, right? } out.println("<HTML><HEAD><TITLE>Hello World</TITLE></HEAD><BODY>"); if (safename == null) { String nobody = messages.getString("nobody"); out.println(nobody); } else { out.println("Hello, " + safename); } out.println("</BODY></HTML>"); }
From source file:de.weltraumschaf.citer.resources.api.RandomCiteResource.java
@Produces(MediaType.TEXT_HTML) @GET/*from w w w. j a va 2 s. c om*/ public String html() { Cite cite = getRandomCite(); if (null == cite) { return ""; } String text = StringEscapeUtils.escapeHtml4(cite.getText()); String name = StringEscapeUtils.escapeHtml4(cite.getOriginator().getName()); return String.format("<cite>%s</cite> (%s)", text, name); }
From source file:joliex.util.HTMLUtils.java
public String escapeHTML(String s) { return StringEscapeUtils.escapeHtml4(s); }
From source file:com.yonyou.dms.function.utils.common.StringUtils.java
/** * escape html str */ public static String escapeHtml(String str) { return StringEscapeUtils.escapeHtml4(str); }
From source file:de.blizzy.documentr.markdown.macro.impl.TabData.java
String renderTab(String id, boolean active) { return "<li" + (active ? " class=\"active\"" : StringUtils.EMPTY) + ">" + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ "<a href=\"#" + id + "\" data-toggle=\"tab\">" + //$NON-NLS-1$ //$NON-NLS-2$ StringEscapeUtils.escapeHtml4(title) + "</a>" + //$NON-NLS-1$ "</li>"; //$NON-NLS-1$ }
From source file:com.cognifide.aet.job.common.collectors.accessibility.AccessibilityIssueDeserializer.java
@Override public AccessibilityIssue deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext jsonDeserializationContext) { JsonObject jo = json.getAsJsonObject(); String message = jo.get("message").getAsString(); String code = jo.get("code").getAsString(); IssueType type = IssueType.byValue(jo.get("type").getAsString()); JsonElement jsonElement = jo.get("elementString"); String elementString = NULL_ELEMENT_STRING; if (jsonElement != null) { elementString = jsonElement.getAsString(); }// w w w .j av a2s . co m String elementStringAbbrv = StringEscapeUtils.escapeHtml4(elementString); elementStringAbbrv = StringUtils.abbreviateMiddle(elementStringAbbrv, "...", MAX_PRE_STRING_LENGTH); return new AccessibilityIssue(type, message, code, elementString, elementStringAbbrv); }
From source file:com.yunmel.syncretic.core.BaseController.java
@InitBinder public void initBinder(WebDataBinder binder) { // String??StringHTML?XSS binder.registerCustomEditor(String.class, new PropertyEditorSupport() { @Override/*ww w . j av a 2 s. com*/ public void setAsText(String text) { setValue(text == null ? null : StringEscapeUtils.escapeHtml4(text.trim())); } @Override public String getAsText() { Object value = getValue(); return value != null ? value.toString() : ""; } }); // Date ? binder.registerCustomEditor(Date.class, new PropertyEditorSupport() { @Override public void setAsText(String text) { try { setValue(DateUtils.parseDate(text, "yyyy-MM-dd HH:mm:ss")); } catch (ParseException e) { e.printStackTrace(); } } }); // Timestamp ? binder.registerCustomEditor(Timestamp.class, new PropertyEditorSupport() { @Override public void setAsText(String text) { Date date = null; try { date = DateUtils.parseDate(text, "yyyy-MM-dd HH:mm:ss"); } catch (ParseException e) { e.printStackTrace(); } setValue(date == null ? null : new Timestamp(date.getTime())); } }); }