1- component extends = " org.lucee.cfml.test.LuceeTestCase" {
1+ component extends = " org.lucee.cfml.test.LuceeTestCase" labels = " guard " {
22 function run ( testResults , testBox ) {
33 describe ( title = " Test suite for Canonicalize()" , body = function () {
44 it (title = " checking Canonicalize() function" , body = function ( currentSpec ) {
55 assertEquals (' <' ,canonicalize (" <" ,false ,false ));
66 assertEquals (' < < < <<' ,canonicalize (" %26lt; %26lt; %2526lt%253B %2526lt%253B%2526lt%253B" ,false ,false ));
77 assertEquals (' <' ,canonicalize (" &## X25;3c" ,false ,false ));
88 });
9+
10+
11+ it ( " reduces double-encoded characters (Standard Unmasking)" , function () {
12+ // %25 is '%', so %253c becomes %3c which becomes <
13+ var input = " Hello %253cscript%253e" ;
14+ expect ( canonicalize ( input , false , false ) ).toBe ( " Hello <script>" );
15+ });
16+
17+
18+ it ( " preserves the plus sign (No URL-space conversion)" , function () {
19+ var input = " 1+1=2" ;
20+ // Our Lucee-native decoder ensures + does not become a space
21+ expect ( canonicalize ( input , false , false ) ).toBe ( " 1+1=2" );
22+ });
23+
24+ it ( " preserves all special characters when simplify is disabled" , function () {
25+ var input = " !@## $&*()_+{}[]:;''<>, .?/|~`." ;
26+
27+ // When simplify is false, carets and backslashes remain
28+ expect ( canonicalize ( input , false , false ) ).toBe ( input );
29+ });
30+
31+ it ( " handles mixed HTML and URL encoding" , function () {
32+ // %26 is '&', so %26lt; becomes < which becomes <
33+ var input = " Mixed: %26lt;script%26gt;" ;
34+ expect ( canonicalize ( input , false , false ) ).toBe ( " Mixed: <script>" );
35+ });
36+
937 });
1038 }
1139}
0 commit comments