MCPcopy Index your code
hub / github.com/apache/tomcat / escape

Method escape

java/org/apache/jasper/compiler/Generator.java:128–146  ·  view source on GitHub ↗

@param s the input string - must not be null @return escaped string, per Java rule

(String s)

Source from the content-addressed store, hash-verified

126 * @return escaped string, per Java rule
127 */
128 static String escape(String s) {
129
130 StringBuilder b = new StringBuilder();
131 for (int i = 0; i < s.length(); i++) {
132 char c = s.charAt(i);
133 if (c == '"') {
134 b.append('\\').append('"');
135 } else if (c == '\\') {
136 b.append('\\').append('\\');
137 } else if (c == '\n') {
138 b.append('\\').append('n');
139 } else if (c == '\r') {
140 b.append('\\').append('r');
141 } else {
142 b.append(c);
143 }
144 }
145 return b.toString();
146 }
147
148 /**
149 * Single quote and escape a character

Callers 6

testEscape01Method · 0.95
testEscape02Method · 0.95
testEscape03Method · 0.95
testEscape04Method · 0.95
quoteMethod · 0.95
visitMethod · 0.45

Calls 4

lengthMethod · 0.80
charAtMethod · 0.80
toStringMethod · 0.65
appendMethod · 0.45

Tested by 4

testEscape01Method · 0.76
testEscape02Method · 0.76
testEscape03Method · 0.76
testEscape04Method · 0.76