Skip to content

Commit 74a38b0

Browse files
jackycctkwwall
authored andcommitted
ESAPI#304 encodeForCSS breaks color values (ESAPI#453)
1 parent bbf431a commit 74a38b0

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/main/java/org/owasp/esapi/reference/DefaultEncoder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public static Encoder getInstance() {
8888
*/
8989
private final static char[] IMMUNE_HTML = { ',', '.', '-', '_', ' ' };
9090
private final static char[] IMMUNE_HTMLATTR = { ',', '.', '-', '_' };
91-
private final static char[] IMMUNE_CSS = {};
91+
private final static char[] IMMUNE_CSS = { '#' };
9292
private final static char[] IMMUNE_JAVASCRIPT = { ',', '.', '_' };
9393
private final static char[] IMMUNE_VBSCRIPT = { ',', '.', '_' };
9494
private final static char[] IMMUNE_XML = { ',', '.', '-', '_', ' ' };

src/test/java/org/owasp/esapi/reference/EncoderTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,10 +382,14 @@ public void testEncodeForCSS() {
382382
assertEquals(null, instance.encodeForCSS(null));
383383
assertEquals("\\3c script\\3e ", instance.encodeForCSS("<script>"));
384384
assertEquals("\\21 \\40 \\24 \\25 \\28 \\29 \\3d \\2b \\7b \\7d \\5b \\5d ", instance.encodeForCSS("!@$%()=+{}[]"));
385+
assertEquals("#f00", instance.encodeForCSS("#f00"));
386+
assertEquals("#123456", instance.encodeForCSS("#123456"));
387+
assertEquals("#abcdef", instance.encodeForCSS("#abcdef"));
388+
assertEquals("red", instance.encodeForCSS("red"));
385389
}
386-
387390

388-
391+
392+
389393
/**
390394
* Test of encodeForJavaScript method, of class org.owasp.esapi.Encoder.
391395
*/

0 commit comments

Comments
 (0)