mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-08 01:26:03 +00:00
added XML escape method.
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@3146 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
318fb582a8
commit
6793b72fec
2 files changed
+19
No files matched your search
@@ -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("<");
|
||||
else
|
||||
if(ch=='&')
|
||||
buf.append("&");
|
||||
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');
|
||||
|
||||
Reference in new issue
Block a user