org.apache.commons.lang.StringEscapeUtils.unescapeHtml()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(383)

本文整理了Java中org.apache.commons.lang.StringEscapeUtils.unescapeHtml()方法的一些代码示例,展示了StringEscapeUtils.unescapeHtml()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringEscapeUtils.unescapeHtml()方法的具体详情如下:
包路径:org.apache.commons.lang.StringEscapeUtils
类名称:StringEscapeUtils
方法名:unescapeHtml

StringEscapeUtils.unescapeHtml介绍

[英]Unescapes a string containing entity escapes to a string containing the actual Unicode characters corresponding to the escapes. Supports HTML 4.0 entities.

For example, the string "<Français>" will become "<Français>"

If an entity is unrecognized, it is left alone, and inserted verbatim into the result string. e.g. ">&zzzz;x" will become ">&zzzz;x".
[中]unescape将包含实体转义的字符串转换为包含与转义相对应的实际Unicode字符的字符串。支持HTML4.0实体。
例如,字符串“&lt;Fran&ccedil;ais&gt;”将成为“<Français>”
如果一个实体无法识别,它将被单独保留,并逐字插入结果字符串。e、 g.“&gt;&zzzz;x”将变成“>&zzzz;x”。

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

/**
 * UnEscape HTML content. i.e. replace characters with &values;
 *
 * @param content
 *          content
 * @return unescaped content
 */
public static String unEscapeHtml( String content ) {
 if ( Utils.isEmpty( content ) ) {
  return content;
 }
 return StringEscapeUtils.unescapeHtml( content );
}

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

public String getUnHtmlEncodedValue() {
  if (unHtmlEncodedValue == null) {
    return StringEscapeUtils.unescapeHtml(getValue());
  }
  return unHtmlEncodedValue;
}

代码示例来源:origin: commons-lang/commons-lang

/**
 * <p>Unescapes a string containing entity escapes to a string
 * containing the actual Unicode characters corresponding to the
 * escapes. Supports HTML 4.0 entities.</p>
 *
 * <p>For example, the string "&amp;lt;Fran&amp;ccedil;ais&amp;gt;"
 * will become "&lt;Fran&ccedil;ais&gt;"</p>
 *
 * <p>If an entity is unrecognized, it is left alone, and inserted
 * verbatim into the result string. e.g. "&amp;gt;&amp;zzzz;x" will
 * become "&gt;&amp;zzzz;x".</p>
 *
 * @param str  the <code>String</code> to unescape, may be null
 * @return a new unescaped <code>String</code>, <code>null</code> if null string input
 * @see #escapeHtml(Writer, String)
 */
public static String unescapeHtml(String str) {
  if (str == null) {
    return null;
  }
  try {
    StringWriter writer = new StringWriter ((int)(str.length() * 1.5));
    unescapeHtml(writer, str);
    return writer.toString();
  } catch (IOException ioe) {
    //should be impossible
    throw new UnhandledException(ioe);
  }
}

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

public void setValue(String value) {
  this.value = value;
  if (unHtmlEncodedValue == null && value != null) {
    setUnHtmlEncodedValue(StringEscapeUtils.unescapeHtml(value));
  }
  
  if (rawValue == null && value != null) {
    setRawValue(value);
  }
}

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

protected void cleanEntity(Entity entity) throws ServiceException {
  Property currentProperty = null;
  try {
    for (Property property : entity.getProperties()) {
      currentProperty = property;
      property.setRawValue(property.getValue());
      property.setValue(exploitProtectionService.cleanStringWithResults(property.getValue()));
      property.setUnHtmlEncodedValue(StringEscapeUtils.unescapeHtml(property.getValue()));
    }
  } catch (CleanStringException e) {
    StringBuilder sb = new StringBuilder();
    for (int j=0;j<e.getCleanResults().getNumberOfErrors();j++){
      sb.append("\n");
      sb.append(j+1);
      sb.append(") ");
      sb.append((String) e.getCleanResults().getErrorMessages().get(j));
      sb.append("\n");
    }
    sb.append("\nNote - Antisamy policy in effect. Set a new policy file to modify validation behavior/strictness.");
    entity.addValidationError(currentProperty.getName(), sb.toString());
  }
}

代码示例来源:origin: apache/cloudstack

public void setQueryFilter(String queryFilter) {
  this.queryFilter = StringEscapeUtils.unescapeHtml(queryFilter);
}

代码示例来源:origin: internetarchive/heritrix3

codebase = StringEscapeUtils.unescapeHtml(attrValue);
CharSequence context = elementContext(elementName, attr.getKey());
processEmbed(curi, codebase, context);
  res = StringEscapeUtils.unescapeHtml(res);
  if (codebaseURI != null) {
    res = codebaseURI.resolve(res).toString();

代码示例来源:origin: org.sonatype.security/security-rest-api

@Override
  public Object fromString( String str )
  {
    return StringEscapeUtils.unescapeHtml( str );
  }
}

代码示例来源:origin: spring-cloud/spring-cloud-dataflow

private String unescape(String text) {
    return StringEscapeUtils.unescapeHtml(text);
  }
}

代码示例来源:origin: org.netpreserve.commons/commons-web

/**
 * Replaces HTML Entity Encodings.
 * @param cs The CharSequence to remove html codes from
 * @return the same CharSequence or an escaped String.
 */
public static CharSequence unescapeHtml(final CharSequence cs) {
  if (cs == null) {
    return cs;
  }
  
  return StringEscapeUtils.unescapeHtml(cs.toString());
}

代码示例来源:origin: iipc/webarchive-commons

/**
 * Replaces HTML Entity Encodings.
 * @param cs The CharSequence to remove html codes from
 * @return the same CharSequence or an escaped String.
 */
public static CharSequence unescapeHtml(final CharSequence cs) {
  if (cs == null) {
    return cs;
  }
  
  return StringEscapeUtils.unescapeHtml(cs.toString());
}

代码示例来源:origin: org.sonatype.nexus.plugins/nexus-restlet1x-plugin

@Nullable
 @Override
 public Object apply(@Nullable final Object input) {
  if (input instanceof String) {
   return StringEscapeUtils.unescapeHtml((String) input);
  }
  return input;
 }
}));

代码示例来源:origin: com.atlassian.jira/jira-issue-link-remote-jira-plugin

private String find(final Pattern p, final String s)
  {
    final Matcher m = p.matcher(s);
    if (m.find())
    {
      return StringEscapeUtils.unescapeHtml(m.group(1));
    }
    // Return an empty list if we didn't find it
    return "[]";
  }
}

代码示例来源:origin: sakaiproject/sakai

public void setContent(String text, boolean modified) {
  if (!this.content.equals(text) && modified) {
    modifiedDate = Instant.now().toEpochMilli();
  }
  this.content = StringEscapeUtils.unescapeHtml(text.trim());
}

代码示例来源:origin: gatein/gatein-portal

private String[] getParams(String step) {
  String[] params = new String[3];
  int x = 0;
  int y = 0;
  for (int i = 0; i < 3; i++) {
    x = step.indexOf("<td>", x) + 4;
    y = step.indexOf("\n", x);
    y = step.lastIndexOf("</td>", y);
    params[i] = StringEscapeUtils.unescapeHtml(step.substring(x, y));
  }
  return params;
}

代码示例来源:origin: de.tudarmstadt.ukp.wikipedia/de.tudarmstadt.ukp.wikipedia.revisionmachine

/**
 * Returns the textual content of this revision.
 *
 * @return content
 */
public String getRevisionText()
{
  if (this.revisionText == null) {
    revisionApi.setRevisionTextAndParts(this);
  }
  return StringEscapeUtils.unescapeHtml(this.revisionText);
}

代码示例来源:origin: pentaho/pentaho-platform

protected static ConnectionFactory getConnectionFactory( IDatabaseConnection databaseConnection, String url ) {
 Properties props = new Properties();
 props.put( "user", StringEscapeUtils.unescapeHtml( databaseConnection.getUsername() ) );
 props.put( "password", StringEscapeUtils.unescapeHtml( databaseConnection.getPassword() ) );
 if ( url.startsWith( "jdbc:mysql:" ) || ( url.startsWith( "jdbc:mariadb:" ) ) ) {
  props.put( "connectTimeout", "5000" );
 }
 return new DriverManagerConnectionFactory( url, props );
}

代码示例来源:origin: OpenAttestation/OpenAttestation

public HtmlErrorParser(String html) {
  this.html = html;
  this.serverName = findServerName();
  log.debug("Server name is {}", serverName);
  this.rootCause = StringEscapeUtils.unescapeHtml(findRootCause());
  log.debug("Root cause is {}", rootCause);
}

代码示例来源:origin: ATLANTBH/nutch-plugins

private String filterValue(String value, boolean trim) {
  String returnValue = null;
  
  // Filter out empty strings and strings made of space, carriage return and tab characters
  if(!value.isEmpty() && !FilterUtils.isMadeOf(value, " \n\t")) {
    
    // Trim data?
    returnValue = trimValue(value, trim);
  }
  
  return returnValue == null ? null : StringEscapeUtils.unescapeHtml(returnValue);
}

代码示例来源:origin: pl.edu.icm.synat/synat-portal-core

private void appendKeywords(ResourceData resource, YElement yElement) {
  for (KeywordsData keywordsData : resource.getKeywords()) {
    if (StringUtils.isNotEmpty(keywordsData.getContentString())) {
      YTagList tagList = new YTagList(keywordsData.getLanguage().getyLanguage(), TagTypes.TG_KEYWORD);
      for (Renderable tag : keywordsData.getData()) {
        tagList.addValue(StringEscapeUtils.unescapeHtml(tag.toString()));//TODO QQQ
      }
      yElement.addTagList(tagList);
    }
  }
}

相关文章