Skip to content

Commit

Permalink
fixed files form Lang #46
Browse files Browse the repository at this point in the history
  • Loading branch information
tdurieux committed Mar 7, 2017
1 parent 1dc8be3 commit 96f19e1
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions projects/Lang/46/org/apache/commons/lang/StringEscapeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public StringEscapeUtils() {
* @return String with escaped values, <code>null</code> if null string input
*/
public static String escapeJava(String str) {
return escapeJavaStyleString(str, false);
return escapeJavaStyleString(str, false, false);
}

/**
Expand All @@ -99,7 +99,7 @@ public static String escapeJava(String str) {
* @throws IOException if error occurs on underlying Writer
*/
public static void escapeJava(Writer out, String str) throws IOException {
escapeJavaStyleString(out, str, false);
escapeJavaStyleString(out, str, false, false);
}

/**
Expand All @@ -124,7 +124,7 @@ public static void escapeJava(Writer out, String str) throws IOException {
* @return String with escaped values, <code>null</code> if null string input
*/
public static String escapeJavaScript(String str) {
return escapeJavaStyleString(str, true);
return escapeJavaStyleString(str, true, true);
}

/**
Expand All @@ -140,7 +140,7 @@ public static String escapeJavaScript(String str) {
* @throws IOException if error occurs on underlying Writer
**/
public static void escapeJavaScript(Writer out, String str) throws IOException {
escapeJavaStyleString(out, str, true);
escapeJavaStyleString(out, str, true, true);
}

/**
Expand All @@ -151,13 +151,13 @@ public static void escapeJavaScript(Writer out, String str) throws IOException {
* @param escapeForwardSlash TODO
* @return the escaped string
*/
private static String escapeJavaStyleString(String str, boolean escapeSingleQuotes) {
private static String escapeJavaStyleString(String str, boolean escapeSingleQuotes, boolean escapeForwardSlash) {
if (str == null) {
return null;
}
try {
StringWriter writer = new StringWriter(str.length() * 2);
escapeJavaStyleString(writer, str, escapeSingleQuotes);
escapeJavaStyleString(writer, str, escapeSingleQuotes, escapeForwardSlash);
return writer.toString();
} catch (IOException ioe) {
// this should never ever happen while writing to a StringWriter
Expand All @@ -175,7 +175,8 @@ private static String escapeJavaStyleString(String str, boolean escapeSingleQuot
* @param escapeForwardSlash TODO
* @throws IOException if an IOException occurs
*/
private static void escapeJavaStyleString(Writer out, String str, boolean escapeSingleQuote) throws IOException {
private static void escapeJavaStyleString(Writer out, String str, boolean escapeSingleQuote,
boolean escapeForwardSlash) throws IOException {
if (out == null) {
throw new IllegalArgumentException("The Writer must not be null");
}
Expand Down Expand Up @@ -241,7 +242,9 @@ private static void escapeJavaStyleString(Writer out, String str, boolean escape
out.write('\\');
break;
case '/' :
if (escapeForwardSlash) {
out.write('\\');
}
out.write('/');
break;
default :
Expand Down

0 comments on commit 96f19e1

Please sign in to comment.