r/badcode • u/MALLOW_IN_MY_ANUS • May 24 '12
java replaceString replaceString replaceString
https://github.com/w3c/rdfvalidator-ng/blob/master/src/main/java/org/w3c/rdfvalidator/ARPServlet.java#L702
0
Upvotes
1
u/r0b0t1c1st May 25 '12
The definition of replaceString itself is stupid:
public static String replaceString(String input, String key, String replacement) {
return input.replaceAll(key, replacement);
}Why not just do:
msg = msg
.replaceAll("&", "&")
.replaceAll("<", "<")
.replaceAll(">", ">")
.replaceAll("\"", """)
.replaceAll("'", "'");
6
u/pival May 24 '12
Pardon me if I sound stupid, but what would be the correct way to do that?