提交 6793b72f 编写于 作者: K kohsuke

added XML escape method.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@3146 71c3de6d-444a-0410-be80-ed276b4c234a
上级 318fb582
......@@ -347,6 +347,10 @@ public class Functions {
return Util.escape(s);
}
public static String xmlEscape(String s) {
return Util.xmlEscape(s);
}
public static void adminCheck(StaplerRequest req, StaplerResponse rsp, Object required) throws IOException, ServletException {
if(required!=null && !Hudson.adminCheck(req,rsp)) {
// check failed
......
......@@ -392,6 +392,21 @@ public class Util {
return buf.toString();
}
public static String xmlEscape(String text) {
StringBuffer buf = new StringBuffer(text.length()+64);
for( int i=0; i<text.length(); i++ ) {
char ch = text.charAt(i);
if(ch=='<')
buf.append("&lt;");
else
if(ch=='&')
buf.append("&amp;");
else
buf.append(ch);
}
return buf.toString();
}
private static char toDigit(int n) {
char ch = Character.forDigit(n,16);
if(ch>='a') ch = (char)(ch-'a'+'A');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册