hudson.Util.escape()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(244)

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

Util.escape介绍

[英]Escapes HTML unsafe characters like <, & to the respective character entities.
[中]将不安全的HTML字符(如<、&)转义到相应的字符实体。

代码示例

代码示例来源:origin: jenkinsci/jenkins

  1. public MenuItem withDisplayName(String displayName) {
  2. this.displayName = Util.escape(displayName);
  3. return this;
  4. }

代码示例来源:origin: jenkinsci/jenkins

  1. public static String escape(String s) {
  2. return Util.escape(s);
  3. }

代码示例来源:origin: jenkinsci/jenkins

  1. @Override
  2. public void translate(String markup, Writer output) throws IOException {
  3. output.write(Util.escape(markup));
  4. }

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * Message escaped for HTML
  3. */
  4. public String getMsgEscaped() {
  5. return Util.escape(getMsg());
  6. }

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * Sends out a string error message that indicates an error.
  3. *
  4. * @param message
  5. * Human readable message to be sent. {@code error(null)}
  6. * can be used as {@code ok()}.
  7. */
  8. public void error(String message) throws IOException, ServletException {
  9. errorWithMarkup(message==null?null:Util.escape(message));
  10. }

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * Sends out a string error message that indicates an error.
  3. *
  4. * @param message
  5. * Human readable message to be sent. {@code error(null)}
  6. * can be used as {@code ok()}.
  7. */
  8. public static FormValidation error(String message) {
  9. return errorWithMarkup(message==null?null: Util.escape(message));
  10. }

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * Sends out a string error message that indicates an error.
  3. *
  4. * @param message Human readable message to be sent.
  5. */
  6. public static FormFillFailure error(@Nonnull String message) {
  7. return errorWithMarkup(Util.escape(message));
  8. }

代码示例来源:origin: jenkinsci/jenkins

  1. public void warning(String message) throws IOException, ServletException {
  2. warningWithMarkup(message==null?null:Util.escape(message));
  3. }

代码示例来源:origin: jenkinsci/jenkins

  1. public static FormValidation ok(String message) {
  2. return okWithMarkup(message==null?null:Util.escape(message));
  3. }

代码示例来源:origin: jenkinsci/jenkins

  1. public static FormFillFailure warning(@Nonnull String message) {
  2. return warningWithMarkup(Util.escape(message));
  3. }

代码示例来源:origin: jenkinsci/jenkins

  1. public void ok(String message) throws IOException, ServletException {
  2. okWithMarkup(message==null?null:Util.escape(message));
  3. }

代码示例来源:origin: jenkinsci/jenkins

  1. public static FormValidation warning(String message) {
  2. return warningWithMarkup(message==null?null:Util.escape(message));
  3. }

代码示例来源:origin: jenkinsci/jenkins

  1. private static FormValidation _error(Kind kind, Throwable e, String message) {
  2. if (e==null) return _errorWithMarkup(Util.escape(message),kind);
  3. return _errorWithMarkup(Util.escape(message)+
  4. " <a href='#' class='showDetails'>"
  5. + Messages.FormValidation_Error_Details()
  6. + "</a><pre style='display:none'>"
  7. + Util.escape(Functions.printThrowable(e)) +
  8. "</pre>",kind
  9. );
  10. }

代码示例来源:origin: jenkinsci/jenkins

  1. private static FormFillFailure _error(FormValidation.Kind kind, Throwable e, String message) {
  2. if (e == null) {
  3. return _errorWithMarkup(Util.escape(message), kind);
  4. }
  5. return _errorWithMarkup(Util.escape(message) +
  6. " <a href='#' class='showDetails'>"
  7. + Messages.FormValidation_Error_Details()
  8. + "</a><pre style='display:none'>"
  9. + Util.escape(Functions.printThrowable(e)) +
  10. "</pre>", kind
  11. );
  12. }

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * Returns the fully marked-up text.
  3. *
  4. * @param preEscape
  5. * If true, the escaping is for the {@code <PRE>} context. This leave SP and CR/LF intact.
  6. * If false, the escape is for the normal HTML, thus SP becomes &amp;nbsp; and CR/LF becomes {@code <BR>}
  7. */
  8. public String toString(boolean preEscape) {
  9. if(tags.isEmpty())
  10. return preEscape? Util.xmlEscape(text) : Util.escape(text); // the most common case
  11. Collections.sort(tags);
  12. StringBuilder buf = new StringBuilder();
  13. int copied = 0; // # of chars already copied from text to buf
  14. for (Tag tag : tags) {
  15. if (copied<tag.pos) {
  16. String portion = text.substring(copied, tag.pos);
  17. buf.append(preEscape ? Util.xmlEscape(portion) : Util.escape(portion));
  18. copied = tag.pos;
  19. }
  20. buf.append(tag.markup);
  21. }
  22. if (copied<text.length()) {
  23. String portion = text.substring(copied, text.length());
  24. buf.append(preEscape ? Util.xmlEscape(portion) : Util.escape(portion));
  25. }
  26. return buf.toString();
  27. }

代码示例来源:origin: jenkinsci/jenkins

  1. public TimelineEventList doData(StaplerRequest req, @QueryParameter long min, @QueryParameter long max) throws IOException {
  2. TimelineEventList result = new TimelineEventList();
  3. for (Run r : builds.byTimestamp(min,max)) {
  4. Event e = new Event();
  5. e.start = new Date(r.getStartTimeInMillis());
  6. e.end = new Date(r.getStartTimeInMillis()+r.getDuration());
  7. // due to SimileAjax.HTML.deEntify (in simile-ajax-bundle.js), "&lt;" are transformed back to "<", but not the "&#60";
  8. // to protect against XSS
  9. e.title = Util.escape(r.getFullDisplayName()).replace("&lt;", "&#60;");
  10. // what to put in the description?
  11. // e.description = "Longish description of event "+r.getFullDisplayName();
  12. // e.durationEvent = true;
  13. e.link = req.getContextPath()+'/'+r.getUrl();
  14. BallColor c = r.getIconColor();
  15. e.color = String.format("#%06X",c.getBaseColor().darker().getRGB()&0xFFFFFF);
  16. e.classname = "event-"+c.noAnime().toString()+" " + (c.isAnimated()?"animated":"");
  17. result.add(e);
  18. }
  19. return result;
  20. }

代码示例来源:origin: jenkinsci/jenkins

  1. j.getRootUrl(), Util.escape(l.getName()), l.getUrl(), l.getNodes().size(), l.getClouds().size())
  2. );

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

  1. /**
  2. * Sends out a string error message that indicates an error.
  3. *
  4. * @param message
  5. * Human readable message to be sent. <tt>error(null)</tt>
  6. * can be used as <tt>ok()</tt>.
  7. */
  8. public static FormValidation error(String message) {
  9. return errorWithMarkup(message==null?null: Util.escape(message));
  10. }

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

  1. /**
  2. * Message escaped for HTML
  3. */
  4. public String getMsgEscaped() {
  5. return Util.escape(getMsg());
  6. }

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

  1. private static FormValidation _error(Kind kind, Throwable e, String message) {
  2. if (e==null) return _errorWithMarkup(Util.escape(message),kind);
  3. return _errorWithMarkup(Util.escape(message)+
  4. " <a href='#' class='showDetails'>"
  5. + Messages.FormValidation_Error_Details()
  6. + "</a><pre style='display:none'>"
  7. + Util.escape(Functions.printThrowable(e)) +
  8. "</pre>",kind
  9. );
  10. }

相关文章