Java Code Examples for org.apache.commons.lang.StringEscapeUtils#escapeHtml()
The following examples show how to use
org.apache.commons.lang.StringEscapeUtils#escapeHtml() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: USERFRIENDLYSMTPNotifier.java From juddi with Apache License 2.0 | 6 votes |
static String GetChangeSummary(NotifySubscriptionListener body) { SubscriptionResultsList r = body.getSubscriptionResultsList(); StringWriter sw = new StringWriter(); if (r.getAssertionStatusReport() != null) { JAXB.marshal(r.getAssertionStatusReport(), sw); } else if (r.getBindingDetail() != null) { JAXB.marshal(r.getBindingDetail(), sw); } else if (r.getBusinessDetail() != null) { JAXB.marshal(r.getBusinessDetail(), sw); } else if (r.getBusinessList() != null) { JAXB.marshal(r.getBusinessList(), sw); } else if (r.getRelatedBusinessesList() != null) { JAXB.marshal(r.getRelatedBusinessesList(), sw); } else if (r.getServiceDetail() != null) { JAXB.marshal(r.getServiceDetail(), sw); } else if (r.getServiceList() != null) { JAXB.marshal(r.getServiceList(), sw); } else if (r.getTModelDetail() != null) { JAXB.marshal(r.getTModelDetail(), sw); } else if (r.getTModelList() != null) { JAXB.marshal(r.getTModelList(), sw); } return "<pre>" + StringEscapeUtils.escapeHtml(sw.toString()) + "</pre>"; }
Example 2
Source File: NamedGraphServerHttpProxy.java From BUbiNG with Apache License 2.0 | 6 votes |
public static void generate(final long hashCode, final StringBuilder content, final CharSequence[] successors, boolean notescurl) { content.append("<html>\n<head></head>\n<body>\n"); // This helps in making the page text different even for the same number // of URLs, but not always. content.append("<h1>").append((char)((hashCode & 0xF) + 'A')).append((char)((hashCode >>> 4 & 0xF) + 'A')).append((char)((hashCode >>> 8 & 0xF) + 'A')).append((char)((hashCode >>> 12 & 0xF) + 'A')).append("</h1>\n"); for (final CharSequence s : successors) { String ref = s.toString(); if (!notescurl) ref = StringEscapeUtils.escapeHtml(s.toString()); content.append("<p>Lorem ipsum dolor sit amet <a href=\"" + ref + "\">" + ref + "</a>, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n"); } content.append("</body>\n</html>\n"); }
Example 3
Source File: GetJournalEditServlet.java From big-c with Apache License 2.0 | 6 votes |
private boolean checkStorageInfoOrSendError(JNStorage storage, HttpServletRequest request, HttpServletResponse response) throws IOException { int myNsId = storage.getNamespaceID(); String myClusterId = storage.getClusterID(); String theirStorageInfoString = StringEscapeUtils.escapeHtml( request.getParameter(STORAGEINFO_PARAM)); if (theirStorageInfoString != null) { int theirNsId = StorageInfo.getNsIdFromColonSeparatedString( theirStorageInfoString); String theirClusterId = StorageInfo.getClusterIdFromColonSeparatedString( theirStorageInfoString); if (myNsId != theirNsId || !myClusterId.equals(theirClusterId)) { String msg = "This node has namespaceId '" + myNsId + " and clusterId '" + myClusterId + "' but the requesting node expected '" + theirNsId + "' and '" + theirClusterId + "'"; response.sendError(HttpServletResponse.SC_FORBIDDEN, msg); LOG.warn("Received an invalid request file transfer request from " + request.getRemoteAddr() + ": " + msg); return false; } } return true; }
Example 4
Source File: CommonUtils.java From PhrackCTF-Platform-Team with Apache License 2.0 | 5 votes |
/** * xss过滤器 * @param rawstr * @return */ public static String XSSFilter(String rawstr) { String tmp = StringEscapeUtils.escapeHtml(rawstr); //tmp = StringEscapeUtils.escapeJavaScript(tmp); //tmp = StringEscapeUtils.escapeSql(tmp); return tmp; }
Example 5
Source File: ChannelOverviewTasks.java From spacewalk with GNU General Public License v2.0 | 5 votes |
private void makeMessage(int successes, HttpServletRequest request) { if (successes > 0) { String number = LocalizationService.getInstance() .formatNumber(new Integer(successes)); //create the success message ActionMessages msg = new ActionMessages(); String key; if (successes == 1) { key = "configdiff.schedule.success.singular"; } else { key = "configdiff.schedule.success"; } Object[] args = new Object[1]; args[0] = StringEscapeUtils.escapeHtml(number); //add in the success message msg.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(key, args)); getStrutsDelegate().saveMessages(request, msg); } else { //Something went wrong, tell user! ActionErrors errors = new ActionErrors(); getStrutsDelegate().addError("configdiff.schedule.error", errors); getStrutsDelegate().saveMessages(request, errors); } }
Example 6
Source File: CommonsUtils.java From rebuild with GNU General Public License v3.0 | 5 votes |
/** * @param text * @return * @see org.apache.commons.lang.StringEscapeUtils#escapeHtml(String) */ public static String escapeHtml(Object text) { if (text == null || StringUtils.isBlank(text.toString())) { return StringUtils.EMPTY; } String escape = StringEscapeUtils.escapeHtml(text.toString()); return escape.replace(">", ">"); // `>` for MD }
Example 7
Source File: RhnAction.java From spacewalk with GNU General Public License v2.0 | 5 votes |
/** * Add a success message to the request with any parameters. * * @param req to add the message to * @param msgKey resource key to lookup * @param params String values to fill in */ protected void createMessage(HttpServletRequest req, String msgKey, String[] params) { ActionMessages msg = new ActionMessages(); for (int i = 0; i < params.length; i++) { params[i] = StringEscapeUtils.escapeHtml(params[i]); } msg.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(msgKey, params)); saveMessages(req, msg); }
Example 8
Source File: ZookeeperController.java From jstorm with Apache License 2.0 | 5 votes |
@RequestMapping(value = UIDef.API_V2 + "/zookeeper/node/data", produces = "application/json;") @ResponseBody 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; }
Example 9
Source File: EscapingTool.java From hollow with Apache License 2.0 | 4 votes |
public String html(Object string) { return string == null ? null : StringEscapeUtils.escapeHtml(String.valueOf(string)); }
Example 10
Source File: AbstractMobilePage.java From projectforge-webapp with GNU General Public License v3.0 | 4 votes |
/** * @see StringEscapeUtils#escapeHtml(String) */ protected String escapeHtml(final String str) { return StringEscapeUtils.escapeHtml(str); }
Example 11
Source File: AbstractWidgetRenderer.java From smarthome with Eclipse Public License 2.0 | 4 votes |
protected String escapeHtml(String s) { return StringEscapeUtils.escapeHtml(s); }
Example 12
Source File: LogController.java From jstorm with Apache License 2.0 | 4 votes |
@RequestMapping(value = "/deepSearch", method = RequestMethod.GET) public String deepSearch(@RequestParam(value = "cluster", required = true) String clusterName, @RequestParam(value = "tid", required = true) String topologyId, @RequestParam(value = "key", required = false) String keyword, @RequestParam(value = "caseIgnore", required = false) String caseIgnore, ModelMap model) { clusterName = StringEscapeUtils.escapeHtml(clusterName); topologyId = StringEscapeUtils.escapeHtml(topologyId); boolean _caseIgnore = !StringUtils.isBlank(caseIgnore); int port = UIUtils.getSupervisorPort(clusterName); model.addAttribute("keyword", keyword); List<Future<?>> futures = new ArrayList<>(); ConcurrentLinkedQueue<Map> result = new ConcurrentLinkedQueue<>(); if (filterKeyword(model, keyword)) { NimbusClient client = null; try { keyword = URLEncoder.encode(keyword, "UTF-8"); // encode space and url characters client = NimbusClientManager.getNimbusClient(clusterName); TopologyInfo info = client.getClient().getTopologyInfo(topologyId); String topologyName = info.get_topology().get_name(); List<UIWorkerMetric> workerData = UIMetricUtils.getWorkerMetrics(info.get_metrics().get_workerMetric(), topologyId, 60); String dir = "." + File.separator + topologyName; for (UIWorkerMetric metric : workerData){ String logFile = topologyName + "-worker-" + metric.getPort() + ".log"; String url = String.format("http://%s:%s/logview?cmd=searchLog&file=%s&key=%s&offset=%s&case_ignore=%s", metric.getHost(), port, getFullFile(dir, logFile), keyword, 0, _caseIgnore); futures.add(_backround.submit(new SearchRequest(url, metric.getHost(), metric.getPort(), dir, logFile, result))); } JStormServerUtils.checkFutures(futures); model.addAttribute("result", result); } catch (NotAliveException nae) { model.addAttribute("tip", String.format("The topology: %s is dead.", topologyId)); } catch (Exception e) { NimbusClientManager.removeClient(clusterName); LOG.error(e.getMessage(), e); UIUtils.addErrorAttribute(model, e); } } model.addAttribute("clusterName", clusterName); model.addAttribute("topologyId", topologyId); model.addAttribute("logServerPort", port); model.addAttribute("caseIgnore", _caseIgnore); UIUtils.addTitleAttribute(model, "DeepSearch"); return "deepSearch"; }
Example 13
Source File: Test.java From CodeDefenders with GNU Lesser General Public License v3.0 | 4 votes |
@SuppressWarnings("Duplicates") public String getAsHTMLEscapedString() { return StringEscapeUtils.escapeHtml(getAsString()); }
Example 14
Source File: QueryGeometry.java From datawave with Apache License 2.0 | 4 votes |
public String toGeoJsonFeature() { return "{'type': 'Feature', 'properties': {'function': \"" + StringEscapeUtils.escapeHtml(function) + "\"},'geometry': " + geometry + "}"; }
Example 15
Source File: CheckboxRenderer.java From olat with Apache License 2.0 | 4 votes |
/** * org.olat.presentation.framework.components.Component, org.olat.presentation.framework.render.URLBuilder, org.olat.presentation.framework.translator.Translator, * org.olat.presentation.framework.render.RenderResult, java.lang.String[]) */ @Override public void render(Renderer renderer, StringOutput sb, Component source, URLBuilder ubu, Translator translator, RenderResult renderResult, String[] args) { // default should allow <b> </b> coming from localstring properties (see also http://bugs.olat.org/jira/browse/OLAT-4208) boolean escapeHTML = false; if (args != null && args.length > 0) { for (int i = 0; i < args.length; i++) { if (CheckboxElementComponent.RENDERARG_ESCAPEHTML.equals(args[i])) { escapeHTML = true;// so far used from SelectionTreeComponent, e.q. make the publish render tree safe against special chars in node titles } } } CheckboxElementComponent cec = (CheckboxElementComponent) source; String subStrName = "name=\"" + cec.getGroupingName() + "\""; String key = cec.getKey(); String value = cec.getValue(); if (escapeHTML) { key = StringEscapeUtils.escapeHtml(key); value = StringEscapeUtils.escapeHtml(value); } boolean selected = cec.isSelected(); // read write view String cssClass = cec.getCssClass(); // optional CSS class sb.append("<input type=\"checkbox\" "); sb.append("id=\""); sb.append(cec.getFormDispatchId()); sb.append("\" "); sb.append("class=\"b_checkbox\" "); sb.append(subStrName); sb.append(" value=\""); sb.append(key); sb.append("\""); if (selected) sb.append(" checked=\"checked\" "); if (!source.isEnabled()) { sb.append(" disabled=\"disabled\" "); } else { // use the selection form dispatch id and not the one of the element! sb.append(FormJSHelper.getRawJSFor(cec.getRootForm(), cec.getSelectionElementFormDisId(), cec.getAction())); } sb.append(" />"); if (cssClass != null) sb.append("<span class=\"").append(cssClass).append("\">"); if (StringHelper.containsNonWhitespace(value)) { sb.append("<label class=\"b_checkbox_label\" for=\"").append(cec.getFormDispatchId()).append("\">"); sb.append(value); sb.append("</label>"); } if (cssClass != null) sb.append("</span>"); if (source.isEnabled()) { // add set dirty form only if enabled sb.append(FormJSHelper.getJSStartWithVarDeclaration(cec.getFormDispatchId())); sb.append(FormJSHelper.getSetFlexiFormDirtyForCheckbox(cec.getRootForm(), cec.getFormDispatchId())); sb.append(FormJSHelper.getJSEnd()); } }
Example 16
Source File: GoalEditor.java From MavenHelper with Apache License 2.0 | 4 votes |
@Nullable @Override public String getTooltipTextFor(ListItem listItem) { return StringEscapeUtils.escapeHtml(listItem.description); }
Example 17
Source File: RhnAction.java From spacewalk with GNU General Public License v2.0 | 3 votes |
/** * Add a success message to the request with 1 parameter: * * Your System55 has been updated * * where System55 is the value placed in param1. param1 * * @param req to add the message to * @param msgKey resource key to lookup * @param param1 String value to fill in for the first parameter. * (param1 is HTML escaped as well) */ protected void createSuccessMessage(HttpServletRequest req, String msgKey, String param1) { ActionMessages msg = new ActionMessages(); Object[] args = new Object[1]; args[0] = StringEscapeUtils.escapeHtml(param1); msg.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(msgKey, args)); saveMessages(req, msg); }
Example 18
Source File: MultiOrgUserOverview.java From spacewalk with GNU General Public License v2.0 | 2 votes |
/** * get the user's first name * @return the user's first name */ public String getUserFirstName() { return StringEscapeUtils.escapeHtml(userFirstName); }
Example 19
Source File: Tools.java From rapidminer-studio with GNU Affero General Public License v3.0 | 2 votes |
/** * This method will encode the given string by replacing all forbidden characters by the * appropriate HTML entity. */ public static String escapeHTML(String string) { return StringEscapeUtils.escapeHtml(string); }
Example 20
Source File: AbstractListForm.java From projectforge-webapp with GNU General Public License v3.0 | 2 votes |
/** * For displaying the modified search string for lucene, e. g. "modified searchstring: micromata*" * @param component Needed for {@link Component#getString(String)}. * @param searchString * @return */ public static String getModifiedSearchExpressionLabel(final Component component, final String searchString) { return component.getString("search.lucene.expression") + " " + StringEscapeUtils.escapeHtml(BaseDao.modifySearchString(searchString)); }