From: <fg...@us...> - 2011-04-27 12:50:51
|
Revision: 3435 http://openutils.svn.sourceforge.net/openutils/?rev=3435&view=rev Author: fgiust Date: 2011-04-27 12:50:45 +0000 (Wed, 27 Apr 2011) Log Message: ----------- ELFUNCTIONS-9 Use StringEscapeUtils for escaping javascript texts Modified Paths: -------------- trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/ElStringUtils.java Modified: trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/ElStringUtils.java =================================================================== --- trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/ElStringUtils.java 2011-04-27 12:48:39 UTC (rev 3434) +++ trunk/openutils-elfunctions/src/main/java/net/sourceforge/openutils/elfunctions/ElStringUtils.java 2011-04-27 12:50:45 UTC (rev 3435) @@ -22,6 +22,7 @@ import java.net.URLDecoder; import java.net.URLEncoder; +import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.SystemUtils; import org.apache.commons.lang.WordUtils; @@ -66,14 +67,12 @@ /** * Escapes a javascript string. If "true" is passed as parameter, the string is between ", if false is between ' * @param text the string to be escaped - * @param dbl If "true" the escaped string is returned between ", if false is returned between ' + * @param dbl deprecated - no effect * @return the escaped string between either ' or " */ public static String escapeJsText(String text, boolean dbl) { - String repl = dbl ? "\"" : "'"; - String with = "\\" + repl; - return repl + (text != null ? StringUtils.replace(text, repl, with) : "") + repl; + return StringEscapeUtils.escapeJavaScript(text); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |