StringEscapeUtils.java
10.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
package org.apache.commons.lang3;
import java.io.IOException;
import java.io.Writer;
import org.apache.commons.lang3.text.translate.AggregateTranslator;
import org.apache.commons.lang3.text.translate.CharSequenceTranslator;
import org.apache.commons.lang3.text.translate.EntityArrays;
import org.apache.commons.lang3.text.translate.JavaUnicodeEscaper;
import org.apache.commons.lang3.text.translate.LookupTranslator;
import org.apache.commons.lang3.text.translate.NumericEntityEscaper;
import org.apache.commons.lang3.text.translate.NumericEntityUnescaper;
import org.apache.commons.lang3.text.translate.NumericEntityUnescaper.OPTION;
import org.apache.commons.lang3.text.translate.OctalUnescaper;
import org.apache.commons.lang3.text.translate.UnicodeUnescaper;
import org.apache.commons.lang3.text.translate.UnicodeUnpairedSurrogateRemover;
public class StringEscapeUtils
{
public static final CharSequenceTranslator ESCAPE_CSV;
public static final CharSequenceTranslator ESCAPE_ECMASCRIPT;
public static final CharSequenceTranslator ESCAPE_HTML3;
public static final CharSequenceTranslator ESCAPE_HTML4;
public static final CharSequenceTranslator ESCAPE_JAVA = new LookupTranslator(new String[][] { { "\"", "\\\"" }, { "\\", "\\\\" } }).with(new CharSequenceTranslator[] { new LookupTranslator(EntityArrays.JAVA_CTRL_CHARS_ESCAPE()) }).with(new CharSequenceTranslator[] { JavaUnicodeEscaper.outsideOf(32, 127) });
public static final CharSequenceTranslator ESCAPE_JSON;
@Deprecated
public static final CharSequenceTranslator ESCAPE_XML;
public static final CharSequenceTranslator ESCAPE_XML10;
public static final CharSequenceTranslator ESCAPE_XML11;
public static final CharSequenceTranslator UNESCAPE_CSV = new b();
public static final CharSequenceTranslator UNESCAPE_ECMASCRIPT;
public static final CharSequenceTranslator UNESCAPE_HTML3;
public static final CharSequenceTranslator UNESCAPE_HTML4;
public static final CharSequenceTranslator UNESCAPE_JAVA;
public static final CharSequenceTranslator UNESCAPE_JSON;
public static final CharSequenceTranslator UNESCAPE_XML;
static
{
ESCAPE_ECMASCRIPT = new AggregateTranslator(new CharSequenceTranslator[] { new LookupTranslator(new String[][] { { "'", "\\'" }, { "\"", "\\\"" }, { "\\", "\\\\" }, { "/", "\\/" } }), new LookupTranslator(EntityArrays.JAVA_CTRL_CHARS_ESCAPE()), JavaUnicodeEscaper.outsideOf(32, 127) });
ESCAPE_JSON = new AggregateTranslator(new CharSequenceTranslator[] { new LookupTranslator(new String[][] { { "\"", "\\\"" }, { "\\", "\\\\" }, { "/", "\\/" } }), new LookupTranslator(EntityArrays.JAVA_CTRL_CHARS_ESCAPE()), JavaUnicodeEscaper.outsideOf(32, 127) });
ESCAPE_XML = new AggregateTranslator(new CharSequenceTranslator[] { new LookupTranslator(EntityArrays.BASIC_ESCAPE()), new LookupTranslator(EntityArrays.APOS_ESCAPE()) });
Object localObject = new LookupTranslator(EntityArrays.BASIC_ESCAPE());
LookupTranslator localLookupTranslator = new LookupTranslator(EntityArrays.APOS_ESCAPE());
String[] arrayOfString1 = { "\013", "" };
String[] arrayOfString2 = { "\034", "" };
String[] arrayOfString3 = { "", "" };
ESCAPE_XML10 = new AggregateTranslator(new CharSequenceTranslator[] { localObject, localLookupTranslator, new LookupTranslator(new String[][] { { "\000", "" }, { "\001", "" }, { "\002", "" }, { "\003", "" }, { "\004", "" }, { "\005", "" }, { "\006", "" }, { "\007", "" }, { "\b", "" }, arrayOfString1, { "\f", "" }, { "\016", "" }, { "\017", "" }, { "\020", "" }, { "\021", "" }, { "\022", "" }, { "\023", "" }, { "\024", "" }, { "\025", "" }, { "\026", "" }, { "\027", "" }, { "\030", "" }, { "\031", "" }, { "\032", "" }, { "\033", "" }, arrayOfString2, { "\035", "" }, { "\036", "" }, { "\037", "" }, arrayOfString3, { "", "" } }), NumericEntityEscaper.between(127, 132), NumericEntityEscaper.between(134, 159), new UnicodeUnpairedSurrogateRemover() });
localObject = new LookupTranslator(EntityArrays.BASIC_ESCAPE());
localLookupTranslator = new LookupTranslator(EntityArrays.APOS_ESCAPE());
arrayOfString1 = new String[] { "\013", "" };
ESCAPE_XML11 = new AggregateTranslator(new CharSequenceTranslator[] { localObject, localLookupTranslator, new LookupTranslator(new String[][] { { "\000", "" }, arrayOfString1, { "\f", "" }, { "", "" }, { "", "" } }), NumericEntityEscaper.between(1, 8), NumericEntityEscaper.between(14, 31), NumericEntityEscaper.between(127, 132), NumericEntityEscaper.between(134, 159), new UnicodeUnpairedSurrogateRemover() });
ESCAPE_HTML3 = new AggregateTranslator(new CharSequenceTranslator[] { new LookupTranslator(EntityArrays.BASIC_ESCAPE()), new LookupTranslator(EntityArrays.ISO8859_1_ESCAPE()) });
ESCAPE_HTML4 = new AggregateTranslator(new CharSequenceTranslator[] { new LookupTranslator(EntityArrays.BASIC_ESCAPE()), new LookupTranslator(EntityArrays.ISO8859_1_ESCAPE()), new LookupTranslator(EntityArrays.HTML40_EXTENDED_ESCAPE()) });
ESCAPE_CSV = new a();
localObject = new AggregateTranslator(new CharSequenceTranslator[] { new OctalUnescaper(), new UnicodeUnescaper(), new LookupTranslator(EntityArrays.JAVA_CTRL_CHARS_UNESCAPE()), new LookupTranslator(new String[][] { { "\\\\", "\\" }, { "\\\"", "\"" }, { "\\'", "'" }, { "\\", "" } }) });
UNESCAPE_JAVA = (CharSequenceTranslator)localObject;
UNESCAPE_ECMASCRIPT = (CharSequenceTranslator)localObject;
UNESCAPE_JSON = UNESCAPE_JAVA;
UNESCAPE_HTML3 = new AggregateTranslator(new CharSequenceTranslator[] { new LookupTranslator(EntityArrays.BASIC_UNESCAPE()), new LookupTranslator(EntityArrays.ISO8859_1_UNESCAPE()), new NumericEntityUnescaper(new NumericEntityUnescaper.OPTION[0]) });
UNESCAPE_HTML4 = new AggregateTranslator(new CharSequenceTranslator[] { new LookupTranslator(EntityArrays.BASIC_UNESCAPE()), new LookupTranslator(EntityArrays.ISO8859_1_UNESCAPE()), new LookupTranslator(EntityArrays.HTML40_EXTENDED_UNESCAPE()), new NumericEntityUnescaper(new NumericEntityUnescaper.OPTION[0]) });
UNESCAPE_XML = new AggregateTranslator(new CharSequenceTranslator[] { new LookupTranslator(EntityArrays.BASIC_UNESCAPE()), new LookupTranslator(EntityArrays.APOS_UNESCAPE()), new NumericEntityUnescaper(new NumericEntityUnescaper.OPTION[0]) });
}
public static final String escapeCsv(String paramString)
{
return ESCAPE_CSV.translate(paramString);
}
public static final String escapeEcmaScript(String paramString)
{
return ESCAPE_ECMASCRIPT.translate(paramString);
}
public static final String escapeHtml3(String paramString)
{
return ESCAPE_HTML3.translate(paramString);
}
public static final String escapeHtml4(String paramString)
{
return ESCAPE_HTML4.translate(paramString);
}
public static final String escapeJava(String paramString)
{
return ESCAPE_JAVA.translate(paramString);
}
public static final String escapeJson(String paramString)
{
return ESCAPE_JSON.translate(paramString);
}
@Deprecated
public static final String escapeXml(String paramString)
{
return ESCAPE_XML.translate(paramString);
}
public static String escapeXml10(String paramString)
{
return ESCAPE_XML10.translate(paramString);
}
public static String escapeXml11(String paramString)
{
return ESCAPE_XML11.translate(paramString);
}
public static final String unescapeCsv(String paramString)
{
return UNESCAPE_CSV.translate(paramString);
}
public static final String unescapeEcmaScript(String paramString)
{
return UNESCAPE_ECMASCRIPT.translate(paramString);
}
public static final String unescapeHtml3(String paramString)
{
return UNESCAPE_HTML3.translate(paramString);
}
public static final String unescapeHtml4(String paramString)
{
return UNESCAPE_HTML4.translate(paramString);
}
public static final String unescapeJava(String paramString)
{
return UNESCAPE_JAVA.translate(paramString);
}
public static final String unescapeJson(String paramString)
{
return UNESCAPE_JSON.translate(paramString);
}
public static final String unescapeXml(String paramString)
{
return UNESCAPE_XML.translate(paramString);
}
static final class a
extends CharSequenceTranslator
{
private static final String b = "\"";
private static final char[] c = { 44, 34, 13, 10 };
public final int translate(CharSequence paramCharSequence, int paramInt, Writer paramWriter)
throws IOException
{
if (paramInt != 0) {
throw new IllegalStateException("CsvEscaper should never reach the [1] index");
}
if (StringUtils.containsNone(paramCharSequence.toString(), c)) {
paramWriter.write(paramCharSequence.toString());
}
for (;;)
{
return Character.codePointCount(paramCharSequence, 0, paramCharSequence.length());
paramWriter.write(34);
paramWriter.write(StringUtils.replace(paramCharSequence.toString(), b, b + b));
paramWriter.write(34);
}
}
}
static final class b
extends CharSequenceTranslator
{
private static final String b = "\"";
private static final char[] c = { 44, 34, 13, 10 };
public final int translate(CharSequence paramCharSequence, int paramInt, Writer paramWriter)
throws IOException
{
if (paramInt != 0) {
throw new IllegalStateException("CsvUnescaper should never reach the [1] index");
}
if ((paramCharSequence.charAt(0) != '"') || (paramCharSequence.charAt(paramCharSequence.length() - 1) != '"'))
{
paramWriter.write(paramCharSequence.toString());
return Character.codePointCount(paramCharSequence, 0, paramCharSequence.length());
}
String str = paramCharSequence.subSequence(1, paramCharSequence.length() - 1).toString();
if (StringUtils.containsAny(str, c)) {
paramWriter.write(StringUtils.replace(str, b + b, b));
}
for (;;)
{
return Character.codePointCount(paramCharSequence, 0, paramCharSequence.length());
paramWriter.write(paramCharSequence.toString());
}
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/org/apache/commons/lang3/StringEscapeUtils.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/