@@ -1046,25 +1046,53 @@ describe("detectRenderModeHints", () => {
10461046 }
10471047 } ) ;
10481048
1049- it . each ( [
1050- [ "dot-dot segments" , "../outside-scene.html" ] ,
1051- [ "an encoded ../" , "%2e%2e%2foutside-scene.html" ] ,
1052- [ "a leading slash and dot-dot" , "/../outside-scene.html" ] ,
1053- [ "an encoded leading slash and dot-dot" , "%2f%2e%2e%2foutside-scene.html" ] ,
1054- ] ) ( "compileForRender refuses a data-composition-src that leaves the project through %s" , async ( _label , src ) => {
1055- const projectDir = makeSubCompProject ( "hf-outside-subcomp-" , [ { id : "intro" , src } ] , { } ) ;
1056- const outside = join ( dirname ( projectDir ) , "outside-scene.html" ) ;
1057- writeFileSync ( outside , validSubCompHtml ( "intro" , "Outside" ) ) ;
1049+ it ( "compileForRender re-points a sibling asset of a sub-composition whose folder is %20-encoded" , async ( ) => {
1050+ const projectDir = makeSubCompProject (
1051+ "hf-encoded-dir-subcomp-" ,
1052+ [ { id : "intro" , src : "my%20dir/scene.html" } ] ,
1053+ { } ,
1054+ ) ;
10581055 try {
1059- await expect (
1060- compileForRender ( projectDir , join ( projectDir , "index.html" ) , projectDir ) ,
1061- ) . rejects . toThrow ( / o u t s i d e t h e p r o j e c t f o l d e r / ) ;
1056+ mkdirSync ( join ( projectDir , "my dir" ) , { recursive : true } ) ;
1057+ writeFileSync ( join ( projectDir , "my dir" , "img.png" ) , "png" ) ;
1058+ writeFileSync (
1059+ join ( projectDir , "my dir" , "scene.html" ) ,
1060+ `<!doctype html><html><body><div data-composition-id="intro" data-width="100" data-height="100"><img id="pic" src="img.png"></div></body></html>` ,
1061+ ) ;
1062+ const compiled = await compileForRender (
1063+ projectDir ,
1064+ join ( projectDir , "index.html" ) ,
1065+ projectDir ,
1066+ ) ;
1067+ const src = parseHTML ( compiled . html ) . document . getElementById ( "pic" ) ?. getAttribute ( "src" ) ;
1068+ expect ( decodeURIComponent ( src ?? "" ) ) . toContain ( "my dir/img.png" ) ;
10621069 } finally {
1063- rmSync ( outside , { force : true } ) ;
10641070 rmSync ( projectDir , { recursive : true , force : true } ) ;
10651071 }
10661072 } ) ;
10671073
1074+ it . each ( [
1075+ [ "dot-dot segments" , "../outside-scene.html" ] ,
1076+ [ "an encoded ../" , "%2e%2e%2foutside-scene.html" ] ,
1077+ [ "a leading slash and dot-dot" , "/../outside-scene.html" ] ,
1078+ [ "an encoded leading slash and dot-dot" , "%2f%2e%2e%2foutside-scene.html" ] ,
1079+ ] ) (
1080+ "compileForRender refuses a data-composition-src that leaves the project through %s" ,
1081+ async ( _label , src ) => {
1082+ const projectDir = makeSubCompProject ( "hf-outside-subcomp-" , [ { id : "intro" , src } ] , { } ) ;
1083+ const outside = join ( dirname ( projectDir ) , "outside-scene.html" ) ;
1084+ writeFileSync ( outside , validSubCompHtml ( "intro" , "Outside" ) ) ;
1085+ try {
1086+ await expect (
1087+ compileForRender ( projectDir , join ( projectDir , "index.html" ) , projectDir ) ,
1088+ ) . rejects . toThrow ( / o u t s i d e t h e p r o j e c t f o l d e r / ) ;
1089+ } finally {
1090+ rmSync ( outside , { force : true } ) ;
1091+ rmSync ( projectDir , { recursive : true , force : true } ) ;
1092+ }
1093+ } ,
1094+ ) ;
1095+
10681096 it ( "compileForRender preserves a bare fragment's markup, sibling styles, and script" , async ( ) => {
10691097 const projectDir = makeSubCompProject (
10701098 "hf-fragment-subcomp-" ,
0 commit comments