Java Code Examples for org.apache.commons.lang3.StringEscapeUtils#escapeEcmaScript()

The following examples show how to use org.apache.commons.lang3.StringEscapeUtils#escapeEcmaScript() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomHttpServletRequestWrapper.java    From jeesuite-libs with Apache License 2.0 5 votes vote down vote up
@Override    
public String getParameter(String name) {    
     String value = super.getParameter(name);    
       if (value != null) {    
           value = StringEscapeUtils.escapeEcmaScript(value);    
       }    
       return value;    
}
 
Example 2
Source File: CustomHttpServletRequestWrapper.java    From jeesuite-libs with Apache License 2.0 5 votes vote down vote up
@Override  
public String[] getParameterValues(String name) {  
     String[] values = super.getParameterValues(name);  
     if(values != null && values.length > 0){  
         for(int i =0; i< values.length ;i++){  
             values[i] = StringEscapeUtils.escapeEcmaScript(values[i]);  
         }  
     }  
    return values;  
 }
 
Example 3
Source File: CustomHttpServletRequestWrapper.java    From jeesuite-libs with Apache License 2.0 5 votes vote down vote up
@Override    
public String getHeader(String name) {    
   
       String value = super.getHeader(name);    
       if (value != null) {    
           value = StringEscapeUtils.escapeEcmaScript(value);    
       }    
       return value;    
   }
 
Example 4
Source File: JavascriptEscapeEngine.java    From jtwig-core with Apache License 2.0 4 votes vote down vote up
@Override
public String escape(String input) {
    return StringEscapeUtils.escapeEcmaScript(input);
}
 
Example 5
Source File: SnippetTag.java    From website with GNU Affero General Public License v3.0 4 votes vote down vote up
private String escape(String value) {
	if (isEscapeJavascript()) {
		return StringEscapeUtils.escapeEcmaScript(value); 
	}
	return value;
}
 
Example 6
Source File: EncodersImpl.java    From portals-pluto with Apache License 2.0 4 votes vote down vote up
@Override
public String js(String code) {
	return StringEscapeUtils.escapeEcmaScript(code);
}
 
Example 7
Source File: EscapeTool.java    From velocity-tools with Apache License 2.0 3 votes vote down vote up
/**
 * <p>Escapes the characters in a <code>String</code> using JavaScript String rules.</p>
 * <p>Delegates the process to {@link StringEscapeUtils#escapeEcmaScript(String)}.</p>
 *
 * @param string the string to escape values, may be null
 * @return String with escaped values, <code>null</code> if null string input
 *
 * @see StringEscapeUtils#escapeEcmaScript(String)
 */
public String javascript(Object string)
{
    if (string == null)
    {
        return null;
    }
    return StringEscapeUtils.escapeEcmaScript(String.valueOf(string));
}
 
Example 8
Source File: RhnTagFunctions.java    From uyuni with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Escape the characters in a String using JavaScript String rules.
 *
 * @param param to be escaped
 * @return escaped string
 */
public static String escapeJS(String param) {
    return StringEscapeUtils.escapeEcmaScript(param);
}
 
Example 9
Source File: EscapeJavaScriptReference.java    From velocity-engine with Apache License 2.0 2 votes vote down vote up
/**
 * Escapes the characters in a String to be suitable for use in JavaScript.
 *
 * @param text
 * @return An escaped String.
 * @see <a href="http://commons.apache.org/proper/commons-lang/javadocs/api-release/org/apache/commons/lang3/StringEscapeUtils.html#escapeEcmaScript%28java.lang.String%29">StringEscapeUtils</a>
 */
protected String escape(Object text)
{
    return StringEscapeUtils.escapeEcmaScript(text.toString());
}