Java Code Examples for org.owasp.encoder.Encode#forJavaScriptSource()
The following examples show how to use
org.owasp.encoder.Encode#forJavaScriptSource() .
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: SanitizerHandlerTest.java From light-4j with Apache License 2.0 | 6 votes |
@Test public void testEncoder() throws Exception { String s1 = "keep-alive"; String s2 = "text/html"; Assert.assertEquals(Encode.forJavaScriptSource(s1), s1); Assert.assertEquals(Encode.forJavaScriptSource(s2), s2); String s3 = "<script>alert('test')</script>"; String e3 = Encode.forJavaScriptSource(s3); System.out.println("source = " + e3); String e4 = Encode.forJavaScriptAttribute(s3); System.out.println("attribute = " + e4); String e5 = Encode.forJavaScriptBlock(s3); System.out.println("block = " + e5); String e6 = Encode.forJavaScript(e3); System.out.println("script = " + e6); Assert.assertNotEquals(e3, s3); String s7 = "<script>location.href=\"respources.html\"</script>"; String e7 = Encode.forJavaScriptSource(s7); System.out.println("e7 = " + e7); }
Example 2
Source File: DefaultEncoding.java From light-4j with Apache License 2.0 | 4 votes |
@Override public String apply(String data) { return Encode.forJavaScriptSource(data); }
Example 3
Source File: EncoderTest.java From light-4j with Apache License 2.0 | 4 votes |
@Test public void testForJavaScriptSource() { String result = Encode.forJavaScriptSource(s); System.out.println("JavaScriptSource: " + result); }
Example 4
Source File: ForJavaScriptSourceTag.java From owasp-java-encoder with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void doTag() throws JspException, IOException { Encode.forJavaScriptSource(getJspContext().getOut(), _value); }
Example 5
Source File: EncodeHostObject.java From carbon-apimgt with Apache License 2.0 | 4 votes |
public static String jsFunction_forJavaScriptSource(Context cx, Scriptable thisObj, Object[] args, Function funObj) throws APIManagementException{ return Encode.forJavaScriptSource(validateInput(args)); }