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

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

本文整理了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

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

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

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

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

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

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

/**
 * Message escaped for HTML
 */
public String getMsgEscaped() {
  return Util.escape(getMsg());
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/**
 * Returns the fully marked-up text.
 *
 * @param preEscape
 *      If true, the escaping is for the {@code <PRE>} context. This leave SP and CR/LF intact.
 *      If false, the escape is for the normal HTML, thus SP becomes &amp;nbsp; and CR/LF becomes {@code <BR>}
 */
public String toString(boolean preEscape) {
  if(tags.isEmpty())
    return preEscape? Util.xmlEscape(text) : Util.escape(text);  // the most common case
  Collections.sort(tags);
  StringBuilder buf = new StringBuilder();
  int copied = 0; // # of chars already copied from text to buf
  for (Tag tag : tags) {
    if (copied<tag.pos) {
      String portion = text.substring(copied, tag.pos);
      buf.append(preEscape ? Util.xmlEscape(portion) : Util.escape(portion));
      copied = tag.pos;
    }
    buf.append(tag.markup);
  }
  if (copied<text.length()) {
    String portion = text.substring(copied, text.length());
    buf.append(preEscape ? Util.xmlEscape(portion) : Util.escape(portion));
  }
  return buf.toString();
}

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

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

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

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

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

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

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

/**
 * Message escaped for HTML
 */
public String getMsgEscaped() {
  return Util.escape(getMsg());
}

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

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

相关文章

微信公众号

最新文章

更多