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:org.opendaylight.aaa.h2.persistence.DomainStore.java
protected Domain deleteDomain(String domainid) throws StoreException { domainid = StringEscapeUtils.escapeHtml4(domainid); Domain deletedDomain = this.getDomain(domainid); if (deletedDomain == null) { return null; }//w w w. j av a 2 s . c om String query = String.format("DELETE FROM DOMAINS WHERE domainid = '%s'", domainid); try (Connection conn = dbConnect(); Statement statement = conn.createStatement()) { int deleteCount = statement.executeUpdate(query); LOG.debug("deleted {} records", deleteCount); return deletedDomain; } catch (SQLException e) { LOG.error("Error deleting domain {}", domainid, e); throw new StoreException("Error deleting domain", e); } }
From source file:org.opendaylight.aaa.h2.persistence.GrantStore.java
protected Grant deleteGrant(String grantid) throws StoreException { grantid = StringEscapeUtils.escapeHtml4(grantid); Grant savedGrant = this.getGrant(grantid); if (savedGrant == null) { return null; }//from w w w .j a va 2 s.c om String query = String.format("DELETE FROM GRANTS WHERE grantid = '%s'", grantid); try (Connection conn = dbConnect(); Statement statement = conn.createStatement()) { int deleteCount = statement.executeUpdate(query); LOG.debug("deleted {} records", deleteCount); return savedGrant; } catch (SQLException s) { throw new StoreException("SQL Exception : " + s); } }
From source file:org.opendaylight.aaa.h2.persistence.RoleStore.java
protected Role deleteRole(String roleid) throws StoreException { roleid = StringEscapeUtils.escapeHtml4(roleid); Role savedRole = this.getRole(roleid); if (savedRole == null) { return null; }/*from w w w.j a va2 s . c om*/ String query = String.format("DELETE FROM ROLES WHERE roleid = '%s'", roleid); try (Connection conn = dbConnect(); Statement statement = conn.createStatement()) { int deleteCount = statement.executeUpdate(query); LOG.debug("deleted {} records", deleteCount); return savedRole; } catch (SQLException s) { throw new StoreException("SQL Exception : " + s); } }
From source file:org.opendaylight.aaa.h2.persistence.UserStore.java
protected User deleteUser(String userid) throws StoreException { userid = StringEscapeUtils.escapeHtml4(userid); User savedUser = this.getUser(userid); if (savedUser == null) { return null; }/*from www.j av a2s . com*/ String query = String.format("DELETE FROM USERS WHERE userid = '%s'", userid); try (Connection conn = dbConnect(); Statement statement = conn.createStatement()) { int deleteCount = statement.executeUpdate(query); LOG.debug("deleted {} records", deleteCount); return savedUser; } catch (SQLException s) { throw new StoreException("SQL Exception : " + s); } }
From source file:org.openecomp.sdc.common.util.HtmlCleaner.java
public static String stripHtml(String input, boolean toEscape) { if (input == null || true == input.isEmpty()) { return input; }/*from w ww . j a v a2 s . co m*/ Matcher matcher = onlyTagPattern.matcher(input); Set<String> tagsToRemove = new HashSet<>(); while (matcher.find()) { int start = matcher.start(); int end = matcher.end(); String matchTag = input.substring(start, end); int groupCount = matcher.groupCount(); if (groupCount > 0) { String tag = matcher.group(1); if (tag != null && htmlTags.contains(tag.toLowerCase())) { if (false == tagsToRemove.contains(matchTag)) { tagsToRemove.add(matchTag); } } } } String stripHtmlStr = removeTagsFromString(tagsToRemove, input); if (stripHtmlStr != null) { if (true == toEscape) { stripHtmlStr = StringEscapeUtils.escapeHtml4(stripHtmlStr); } } return stripHtmlStr; }
From source file:org.openecomp.sdc.common.util.ValidationUtils.java
public static String convertHtmlTagsToEntities(String input) { return StringEscapeUtils.escapeHtml4(input); }
From source file:org.owasp.webgoat.service.SourceService.java
/** * Returns source for current attack/*from w w w . ja v a 2s .co m*/ * * @param session a {@link javax.servlet.http.HttpSession} object. * @return a {@link java.lang.String} object. */ @RequestMapping(value = "/source.mvc", produces = "application/text") public @ResponseBody String showSource(HttpSession session) { WebSession ws = getWebSession(session); String source = getSource(ws); if (source == null) { source = "No source listing found"; } return StringEscapeUtils.escapeHtml4(source); }
From source file:org.projectnyx.command.UIText.java
/** * <p>Returns an HTML-encoded text for a specific command issuer.</p> * * <p>The default implementation redirects to {@link #get(CommandIssuer)} and escapes special HTML characters in * it.</p>/* w w w . j a v a2s . c om*/ * * @param issuer the {@link CommandIssuer} to preprocess for or {@code null}. * @return HTML-encoded text * @see #get(CommandIssuer) */ public default String asHTML(CommandIssuer issuer) { return StringEscapeUtils.escapeHtml4(get(issuer)); }
From source file:org.qifu.controller.CommonAction.java
@ControllerMethodAuthority(check = true, programId = "CORE_PROGCOMM0002Q") @RequestMapping(value = "/core.getCommonProgramFolderMenuItemJson.do") public @ResponseBody DefaultControllerJsonResultObj<Map<String, String>> doQueryProgramList( HttpServletRequest request, @RequestParam(name = "oid") String oid) { DefaultControllerJsonResultObj<Map<String, String>> result = this .getDefaultJsonResult("CORE_PROGCOMM0002Q"); if (!this.isAuthorizeAndLoginFromControllerJsonResult(result)) { result.setValue(this.getPleaseSelectMap(true)); return result; }//ww w . j a v a 2 s . com try { TbSys sys = this.findSys(oid); List<SysProgVO> menuProgList = this.sysProgService.findForInTheFolderMenuItems(sys.getSysId(), null, null); Map<String, String> dataMap = this.getPleaseSelectMap(true); for (int i = 0; menuProgList != null && i < menuProgList.size(); i++) { SysProgVO sysProg = menuProgList.get(i); dataMap.put(sysProg.getOid(), StringEscapeUtils.escapeHtml4(sysProg.getName())); } result.setValue(dataMap); result.setSuccess(YES); } catch (AuthorityException | ServiceException | ControllerException e) { result.setMessage(e.getMessage().toString()); } catch (Exception e) { exceptionResult(result, e); } return result; }
From source file:org.qifu.ui.UIComponentValueUtils.java
private static void putValue(Map<String, Object> params, String paramMapKey, Object val, boolean escapeHtml, boolean ecmaScript) { if (val == null) { return;// w w w . ja v a 2s. c o m } if (val instanceof java.lang.String) { params.put(paramMapKey, String.valueOf(val)); if (ecmaScript) { params.put(paramMapKey, StringEscapeUtils.escapeEcmaScript((String) val)); } if (escapeHtml) { params.put(paramMapKey, StringEscapeUtils.escapeHtml4((String) val)); } if (ecmaScript && escapeHtml) { params.put(paramMapKey, StringEscapeUtils.escapeHtml4(StringEscapeUtils.escapeEcmaScript((String) val))); } return; } if (val instanceof java.lang.Integer) { params.put(paramMapKey, String.valueOf((Integer) val)); return; } if (val instanceof java.lang.Long) { params.put(paramMapKey, String.valueOf((Long) val)); return; } if (val instanceof java.math.BigDecimal) { params.put(paramMapKey, ((java.math.BigDecimal) val).toString()); return; } if (val instanceof java.math.BigInteger) { params.put(paramMapKey, ((java.math.BigInteger) val).toString()); return; } if (val instanceof java.lang.Float) { params.put(paramMapKey, String.valueOf((Float) val)); return; } if (val instanceof java.lang.Double) { params.put(paramMapKey, String.valueOf((Double) val)); return; } params.put(paramMapKey, String.valueOf(val)); }