当前位置: 首页>>代码示例>>Java>>正文


Java HtmlSanitizer.sanitize方法代码示例

本文整理汇总了Java中org.owasp.html.HtmlSanitizer.sanitize方法的典型用法代码示例。如果您正苦于以下问题:Java HtmlSanitizer.sanitize方法的具体用法?Java HtmlSanitizer.sanitize怎么用?Java HtmlSanitizer.sanitize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.owasp.html.HtmlSanitizer的用法示例。


在下文中一共展示了HtmlSanitizer.sanitize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sanitize

import org.owasp.html.HtmlSanitizer; //导入方法依赖的package包/类
public Pair<String, List<StreamItemMedia>> sanitize(String input) {
  List<StreamItemMedia> media = new ArrayList<>();
  Appendable htmlOutput = new StringBuilder();
  ImageAwareHtmlRenderer htmlRenderer = new ImageAwareHtmlRenderer(htmlOutput, media);
  HtmlSanitizer.sanitize(input, createPolicy(htmlRenderer));
  return Pair.of(htmlOutput.toString(), media);
}
 
开发者ID:adrobisch,项目名称:putput,代码行数:8,代码来源:MediaAwareSanitizer.java

示例2: main

import org.owasp.html.HtmlSanitizer; //导入方法依赖的package包/类
/**
 * A test-bed that reads HTML from stdin and writes sanitized content to
 * stdout.
 */
public static void main(String[] args) throws IOException {
  if (args.length != 0) {
    System.err.println("Reads from STDIN and writes to STDOUT");
    System.exit(-1);
  }
  System.err.println("[Reading from STDIN]");
  // Fetch the HTML to sanitize.
  String html = CharStreams.toString(
      new InputStreamReader(System.in, Charsets.UTF_8));
  // Set up an output channel to receive the sanitized HTML.
  HtmlStreamRenderer renderer = HtmlStreamRenderer.create(
      System.out,
      // Receives notifications on a failure to write to the output.
      new Handler<IOException>() {
        public void handle(IOException ex) {
          Throwables.propagate(ex);  // System.out suppresses IOExceptions
        }
      },
      // Our HTML parser is very lenient, but this receives notifications on
      // truly bizarre inputs.
      new Handler<String>() {
        public void handle(String x) {
          throw new AssertionError(x);
        }
      });
  // Use the policy defined above to sanitize the HTML.
  HtmlSanitizer.sanitize(html, POLICY_DEFINITION.apply(renderer));
}
 
开发者ID:OWASP,项目名称:java-html-sanitizer,代码行数:33,代码来源:EbayPolicyExample.java

示例3: sanitize

import org.owasp.html.HtmlSanitizer; //导入方法依赖的package包/类
public static String sanitize(String html) {
    StringBuilder sb = new StringBuilder();

    HtmlSanitizer.sanitize(html, makePolicy(sb));

    return sb.toString();
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:8,代码来源:InfoTextHtmlSanitizer.java


注:本文中的org.owasp.html.HtmlSanitizer.sanitize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。