diff --git a/src/lime/utils/AssetLibrary.hx b/src/lime/utils/AssetLibrary.hx index a33ae9b63..1e26d839b 100644 --- a/src/lime/utils/AssetLibrary.hx +++ b/src/lime/utils/AssetLibrary.hx @@ -721,7 +721,7 @@ class AssetLibrary if (Reflect.hasField(asset, "path")) { - paths.set(id, __cacheBreak(basePath + Reflect.field(asset, "path"))); + paths.set(id, __cacheBreak(__resolvePath(basePath + Reflect.field(asset, "path")))); } if (Reflect.hasField(asset, "pathGroup")) @@ -730,7 +730,7 @@ class AssetLibrary for (i in 0...pathGroup.length) { - pathGroup[i] = __cacheBreak(basePath + pathGroup[i]); + pathGroup[i] = __cacheBreak(__resolvePath(basePath + pathGroup[i])); } pathGroups.set(id, pathGroup); @@ -772,6 +772,47 @@ class AssetLibrary } } + @:noCompletion private function __resolvePath(path:String):String + { + path = StringTools.replace(path, "\\", "/"); + path = StringTools.replace(path, "//", "/"); + + if (path.indexOf("./") > -1) + { + var split = path.split("/"); + var newPath = []; + + for (i in 0...split.length) + { + if (split[i] == "..") + { + if (i == 0 || newPath[i - 1] == "..") + { + newPath.push(".."); + } + else + { + newPath.pop(); + } + } + else if (split[i] == ".") + { + if (i == 0) + { + newPath.push("."); + } + } + else + { + newPath.push(split[i]); + } + } + path = newPath.join("/"); + } + + return path; + } + // Event Handlers @:noCompletion private function loadAudioBuffer_onComplete(id:String, audioBuffer:AudioBuffer):Void { diff --git a/src/lime/utils/AssetManifest.hx b/src/lime/utils/AssetManifest.hx index 7e0ba0ae2..67586f265 100644 --- a/src/lime/utils/AssetManifest.hx +++ b/src/lime/utils/AssetManifest.hx @@ -161,7 +161,7 @@ class AssetManifest basePath = path; } - StringTools.replace(basePath, "\\", "/"); + basePath = StringTools.replace(basePath, "\\", "/"); while (StringTools.endsWith(basePath, "/")) { @@ -200,7 +200,7 @@ class AssetManifest rootPath = path; } - StringTools.replace(rootPath, "\\", "/"); + rootPath = StringTools.replace(rootPath, "\\", "/"); while (StringTools.endsWith(rootPath, "/")) {