本文整理了Java中org.apache.commons.lang.StringEscapeUtils.escapeHtml()
方法的一些代码示例,展示了StringEscapeUtils.escapeHtml()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringEscapeUtils.escapeHtml()
方法的具体详情如下:
包路径:org.apache.commons.lang.StringEscapeUtils
类名称:StringEscapeUtils
方法名:escapeHtml
[英]Escapes the characters in a String
using HTML entities and writes them to a Writer
.
For example:"bread" & "butter"
becomes:
"bread" & "butter"
.
Supports all known HTML 4.0 entities, including funky accents. Note that the commonly used apostrophe escape character (') is not a legal entity and so is not supported).
[中]使用HTML实体转义String
中的字符,并将其写入Writer
。
例如:"bread" & "butter"
变成:"bread" & "butter"
.
支持所有已知的HTML4.0实体,包括时髦的口音。请注意,常用的撇号转义字符(')不是法律实体,因此不受支持)。
代码示例来源:origin: KronicDeth/intellij-elixir
private Stream<String> headerHTMLLineStream(@Nullable String header) {
Stream<String> htmlLineStream;
if (header != null) {
htmlLineStream = Stream.of("<h2>" + escapeHtml(header) + "</h2>");
} else {
htmlLineStream = Stream.empty();
}
return htmlLineStream;
}
代码示例来源:origin: pentaho/pentaho-kettle
/**
* Escape HTML content. i.e. replace characters with &values;
*
* @param content
* content
* @return escaped content
*/
public static String escapeHtml( String content ) {
if ( Utils.isEmpty( content ) ) {
return content;
}
return StringEscapeUtils.escapeHtml( content );
}
代码示例来源:origin: KronicDeth/intellij-elixir
@NotNull
private static String preludeContentLineToHTMLLine(@NotNull String contentLine, @NotNull String workingDirectory) {
Matcher explainableMatcher = EXPLAINABLE_PATTERN.matcher(contentLine);
String htmlLine;
if (explainableMatcher.find()) {
String explainable = explainableMatcher.group("explainable");
int before = explainableMatcher.start("explainable");
int after = explainableMatcher.end("explainable");
htmlLine = escapeHtml(contentLine.substring(0, before)) +
"<a href=\"" + navigationHref(workingDirectory, explainableMatcher) + "\">" +
explainable +
"</a>" +
escapeHtml(contentLine.substring(after));
} else {
htmlLine = escapeHtml(contentLine);
}
return htmlLine + "<br/>";
}
代码示例来源:origin: commons-lang/commons-lang
escapeHtml(writer, str);
return writer.toString();
} catch (IOException ioe) {
代码示例来源:origin: SonarSource/sonarqube
public static String convertToHtml(String input) {
return new Markdown().convert(StringEscapeUtils.escapeHtml(input));
}
}
代码示例来源:origin: apache/storm
private static String buildUnauthorizedUserHtml(String user) {
String content = "User '" + escapeHtml(user) + "' is not authorized.";
return body(h2(content)).render();
}
代码示例来源:origin: apache/storm
String logString = isTxtFile(fileName) ? escapeHtml(pageFile(path, isZipFile, fileLength, start, length)) :
escapeHtml("This is a binary file and cannot display! You may download the full file.");
代码示例来源:origin: KronicDeth/intellij-elixir
}).map(unindentedLine -> escapeHtml(unindentedLine) + "<br/>");
} else {
contentHTMLLineStream = Stream.empty();
代码示例来源:origin: internetarchive/heritrix3
/**
* Write the paged HTML.
*
* @see org.restlet.resource.Representation#write(java.io.Writer)
*/
@Override
public void write(Writer writer) throws IOException {
loadLines();
PrintWriter pw = new PrintWriter(writer);
pw.println("<b>Paged view:</b> "+file);
emitControls(pw);
pw.println("<pre>");
emitBumper(pw, true);
for(String line : lines) {
StringEscapeUtils.escapeHtml(pw,line);
pw.println();
}
emitBumper(pw, false);
pw.println("</pre>");
emitControls(pw);
pw.close();
}
代码示例来源:origin: internetarchive/heritrix3
pw.println("<form style='position:absolute;top:15px;bottom:15px;left:15px;right:15px;overflow:auto' method='POST'>");
pw.println("<textarea style='width:98%;height:90%;font-family:monospace' name='contents' id='editor'>");
StringEscapeUtils.escapeHtml(pw,fileRepresentation.getText());
pw.println("</textarea>");
pw.println("<div id='savebar'>");
代码示例来源:origin: apache/storm
String logString = isTxtFile(fileName) ? escapeHtml(pageFile(path, isZipFile, fileLength, start, length)) :
escapeHtml("This is a binary file and cannot display! You may download the full file.");
代码示例来源:origin: azkaban/azkaban
ret.put("length", data.getLength());
ret.put("offset", data.getOffset());
ret.put("data", StringEscapeUtils.escapeHtml(data.getData()));
代码示例来源:origin: apache/storm
private DomContent logTemplate(List<DomContent> bodyContents, String fileName, String user) {
List<DomContent> finalBodyContents = new ArrayList<>();
if (StringUtils.isNotBlank(user)) {
finalBodyContents.add(div(p("User: " + user)).withClass("ui-user"));
}
finalBodyContents.add(div(p("Note: the drop-list shows at most 1024 files for each worker directory.")).withClass("ui-note"));
finalBodyContents.add(h3(escapeHtml(fileName)));
finalBodyContents.addAll(bodyContents);
return html(
head(
title(escapeHtml(fileName) + " - Storm Log Viewer"),
link().withRel("stylesheet").withHref("/css/bootstrap-3.3.1.min.css"),
link().withRel("stylesheet").withHref("/css/jquery.dataTables.1.10.4.min.css"),
link().withRel("stylesheet").withHref("/css/style.css")
),
body(
finalBodyContents.toArray(new DomContent[]{})
)
);
}
代码示例来源:origin: azkaban/azkaban
ret.put("length", data.getLength());
ret.put("offset", data.getOffset());
ret.put("data", StringEscapeUtils.escapeHtml(data.getData()));
代码示例来源:origin: JpressProjects/jpress
setAttr("editFileContent", StringEscapeUtils.escapeHtml(FileUtils.readString(editFile)));
代码示例来源:origin: jbake-org/jbake
public String escape(String s) {
return StringEscapeUtils.escapeHtml(s);
}
}
代码示例来源:origin: Netflix/hollow
@Override
public void write(char[] cbuf, int off, int len) throws IOException {
StringEscapeUtils.escapeHtml(wrappedWriter, new String(cbuf, off, len));
}
代码示例来源:origin: Netflix/hollow
public String html(Object string) {
return string == null ? null : StringEscapeUtils.escapeHtml(String.valueOf(string));
}
代码示例来源:origin: paoding-code/paoding-rose
@Override
public void doRender(Invocation inv) throws Exception {
String message = resolvePlaceHolder(this.message, inv);
message = StringEscapeUtils.escapeHtml(message); //输出到页面之前对HTML转义,防止XSS注入
if (StringUtils.isEmpty(message)) {
inv.getResponse().sendError(code);
} else {
inv.getResponse().sendError(code, message);
}
}
代码示例来源:origin: JpressProjects/jpress
return;
} else {
content = StringEscapeUtils.escapeHtml(content);
内容来源于网络,如有侵权,请联系作者删除!