@@ -8,72 +8,72 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="guard" {
88 it ( " encodes for HTML" , function () {
99 var raw = ' <b> "Test" & '' Check'' </b>' ;
1010 var expected = ' <b> "Test" & &## 39;Check&## 39; </b>' ;
11- expect ( guardEncode (raw , " html" ) ).toBe ( expected );
11+ expect ( guardEncode (" html" , raw ) ).toBe ( expected );
1212 });
1313
1414 it ( " encodes for HTML Attributes" , function () {
1515 var raw = ' "><script>alert(1)</script>' ;
1616 // Attributes are encoded more aggressively than body HTML
17- expect ( guardEncode (raw , " html_attr" ) ).toInclude ( " "" );
18- expect ( guardEncode (raw , " html_attr" ) ).notToInclude ( " >" );
17+ expect ( guardEncode (" html_attr" , raw ) ).toInclude ( " "" );
18+ expect ( guardEncode (" html_attr" , raw ) ).notToInclude ( " >" );
1919 });
2020
2121 it ( " encodes for JavaScript" , function () {
2222 var raw = " '; alert(1); var x='" ;
2323 // Should use hex/unicode escapes for quotes and semicolons
24- var res = guardEncode (raw , " javascript" );
24+ var res = guardEncode (" javascript" , raw );
2525 expect ( res ).toInclude ( " \x27" );
2626 expect ( res ).notToInclude ( " '" );
2727 });
2828
2929 it ( " encodes for CSS" , function () {
3030 var raw = " background: url('javascript:alert(1)')" ;
3131 // CSS encoder escapes non-alphanumerics with backslashes/hex
32- expect ( guardEncode (raw , " css" ) ).toInclude ( " \3a " );
32+ expect ( guardEncode (" css" , raw ) ).toInclude ( " \3a " );
3333 });
3434
3535 it ( " encodes for URL (URI Component)" , function () {
3636 var raw = " John Doe & Sons/Company" ;
37- expect ( guardEncode (raw , " url" ) ).toBe ( " John%20Doe%20%26%20Sons%2FCompany" );
37+ expect ( guardEncode (" url" , raw ) ).toBe ( " John%20Doe%20%26%20Sons%2FCompany" );
3838 });
3939
4040 it ( " encodes for XML and XML Attributes" , function () {
4141 var raw = ' <test value="5"> & ' ;
42- expect ( guardEncode (raw , " xml" ) ).toInclude ( " <" );
43- expect ( guardEncode (raw , " xml_attr" ) ).toInclude ( " "" );
42+ expect ( guardEncode (" xml" , raw ) ).toInclude ( " <" );
43+ expect ( guardEncode (" xml_attr" , raw ) ).toInclude ( " "" );
4444 });
4545
4646 // --- CustomEncoder Targets ---
4747
4848 it ( " encodes for LDAP DN (Distinguished Name)" , function () {
4949 var raw = " Doe, John ## 123" ;
5050 // Should escape the leading # and the comma
51- expect ( guardEncode (raw , " dn" ) ).toBe ( " \## Doe\, John \## 123" );
51+ expect ( guardEncode (" dn" , raw ) ).toBe ( " \## Doe\, John \## 123" );
5252 });
5353
5454 it ( " encodes for LDAP Search Filter" , function () {
5555 var raw = " admin* (test)" ;
5656 // Asterisks and parens must be hex-escaped in filters
57- expect ( guardEncode (raw , " ldap" ) ).toBe ( " admin\2a \28test\29" );
57+ expect ( guardEncode (" ldap" , raw ) ).toBe ( " admin\2a \28test\29" );
5858 });
5959
6060 it ( " encodes for XPath" , function () {
6161 var raw = " ' or 1=1 " ;
62- expect ( guardEncode (raw , " xpath" ) ).toBe ( " &## 39; or 1=1 &## 39; " );
62+ expect ( guardEncode (" xpath" , raw ) ).toBe ( " &## 39; or 1=1 &## 39; " );
6363 });
6464
6565 it ( " encodes for VBScript" , function () {
6666 var raw = " alert!" ;
6767 // Custom VBScript encoder hex-escapes punctuation
68- expect ( guardEncode (raw , " vbscript" ) ).toInclude ( " hex(21)" );
68+ expect ( guardEncode (" vbscript" , raw ) ).toInclude ( " hex(21)" );
6969 });
7070
7171 it ( " encodes for SQL (Multi-Dialect)" , function () {
7272 var raw = " O'Reilly" ;
7373 // Test Oracle/Standard (double quote)
74- expect ( guardEncode (raw , " sql" , false , " oracle" ) ).toBe ( " O''Reilly" );
74+ expect ( guardEncode (" sql" , raw , false , " oracle" ) ).toBe ( " O''Reilly" );
7575 // Test MySQL (backslash)
76- expect ( guardEncode (raw , " sql" , false , " mysql" ) ).toBe ( " O\'Reilly" );
76+ expect ( guardEncode (" sql" , raw , false , " mysql" ) ).toBe ( " O\'Reilly" );
7777 });
7878
7979 // --- Utility Flags ---
@@ -82,7 +82,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="guard" {
8282 // %253c is double encoded '<'
8383 var input = " %253cscript%253e" ;
8484 // If canonicalize=true, it should resolve to <script> then encode for HTML
85- var res = guardEncode (input , " html" , true );
85+ var res = guardEncode ( " html" , input , true );
8686 expect ( res ).toBe ( " <script>" );
8787 });
8888
0 commit comments