Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion editor/js/Loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ function Loader( editor ) {
while ( normalized.startsWith( '../' ) ) normalized = normalized.slice( 3 );
while ( normalized.startsWith( '/' ) ) normalized = normalized.slice( 1 );

try {

normalized = decodeURIComponent( normalized );

} catch ( e ) { /* malformed URI — keep as-is */ }

normalized = normalized.normalize( 'NFC' );

return normalized;

};
Expand Down Expand Up @@ -982,10 +990,22 @@ function Loader( editor ) {

const zip = unzipSync( new Uint8Array( contents ) );

// Build a lookup map with NFC-normalized keys to handle
// unicode normalization differences (e.g. NFD vs NFC)

const zipLookup = {};

for ( const path in zip ) {

zipLookup[ path.normalize( 'NFC' ) ] = zip[ path ];

}

const manager = new THREE.LoadingManager();
manager.setURLModifier( function ( url ) {

const file = zip[ url ];
const normalized = decodeURIComponent( url ).normalize( 'NFC' );
const file = zipLookup[ normalized ];

if ( file ) {

Expand Down
5 changes: 5 additions & 0 deletions src/loaders/LoadingManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ class LoadingManager {
*/
this.resolveURL = function ( url ) {

// Normalize to NFC so that Unicode URIs (e.g. from glTF)
// are percent-encoded correctly per RFC 3987.

url = url.normalize( 'NFC' );

if ( urlModifier ) {

return urlModifier( url );
Expand Down
Loading